-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enabling vsts properties flow to test context #472
Conversation
{ | ||
var tcmProperties = new Dictionary<TestPlatformObjectModel.TestProperty, object>(); | ||
|
||
// Return empty proeprties when testCase is null or when test case id is zero. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (testCase == null || | ||
testCase.GetPropertyValue<int>(Constants.TestCaseIdProperty, default(int)) == 0) | ||
{ | ||
return tcmProperties; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we prefer returning null here and declare tcmProperties variable after this check has passed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done so as to not having null check outside this method context. In case we return null, we can't iterate over it via foreach loop untill there is a null check.
[TestClass] | ||
public class TcmTestPropertiesProviderTests | ||
{ | ||
private const string PropertiesJsonWithDuplicateNamedTestCases = "{ \"TestPlanId\":1, \"TestRunId\":4, \"BuildConfigurationId\":0, \"BuildDirectory\":\"C:\\\\deployment\", \"BuildFlavor\":null, \"BuildNumber\":\"4\", \"BuildPlatform\":null, \"BuildUri\":\"vstfs:///Build/Build/4\", \"TfsServerCollectionUrl\":\"http://server/tfs/DefaultCollection/\", \"TeamProject\":\"teamproject\", \"IsInLabEnvironment\":false, \"LabEnvironment\":null, \"TestCases\":[{\"FullyQualifiedName\":\"PassingTest\",\"Source\":\"unittestproject1.dll\",\"TestCaseId\":1311,\"TestPointId\":11,\"TestConfigurationId\":1,\"TestConfigurationName\":\"Windows 10\"},{\"FullyQualifiedName\":\"PassingTest\",\"Source\":\"unittestproject1.dll\",\"TestCaseId\":1312,\"TestPointId\":12,\"TestConfigurationId\":2,\"TestConfigurationName\":\"Windows 8\"},{\"FullyQualifiedName\":\"PassingTest2\",\"Source\":\"unittestproject2.dll\",\"TestCaseId\":1313,\"TestPointId\":13,\"TestConfigurationId\":2,\"TestConfigurationName\":\"Windows 8\"}]}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we split this across multiple lines please to increase readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed as this was not requried
public void GetTcmPropertiesShouldReturnEmptyDictionaryIfTestCaseIdIsZero() | ||
{ | ||
var testCase = new TestCase("PassingTestFomTestCase", new Uri("http://sampleUri/"), "unittestproject1.dll"); | ||
var propertiesValue = new object[] { 32, 534, 5, "sample build directory", "sample build flavor", "132456", "sample build platform", "http://sampleBuildUti/", "http://samplecollectionuri/", "sample team project", false, 0, 54, "sample configuration name", 345 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Should we add some logging to show what values got filled in for properties? It will help in debugging issues. |
thanks for resolving the issue. I am still not able to get the vsts Properties in testcontext. as per the new changes I tried to access the TCM properties using: |
@anshuls01: Request you to not post queries on closed Pull Requests. Please create separate issue for your queries. Meanwhile, you can refer to this to see how to access these properties. |
Description:
VS IDE has support of association in test explorer. Currently this support is disabled for mstest v2.
Support for mstest v2 will be enabled with this PR: https://devdiv.visualstudio.com/DevDiv/Automated%20Testing/_git/VS/pullrequest/135489?_a=overview
When association is enabled for mstest v2 tests, user can associate mstest v2 tests with a test case and then run it via test plan flow.
In test plan flow, user might need to use tcm properties (like test case id, test run id, test plan id etc) in test method code. This PR contains changes to allow tcm properties to flow to test context.
Validation Scenarios:
Validated that for full framework and net core, tcm properties are properly passed to test context.
Note: In talk with @PBoraMSFT if RFC is required in mstest v2 or not as the flow is controled from IDE. There is a plan to add the documentation on association window in test explorer.