-
Notifications
You must be signed in to change notification settings - Fork 266
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution | ||
{ | ||
using System.Collections.Generic; | ||
using TestPlatformObjectModel = Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
|
||
/// <summary> | ||
/// Reads and parses the TcmTestProperties in order to populate them in TestRunParameters. | ||
/// </summary> | ||
internal static class TcmTestPropertiesProvider | ||
{ | ||
/// <summary> | ||
/// Gets tcm properties from test case. | ||
/// </summary> | ||
/// <param name="testCase">Test case.</param> | ||
/// <returns>Tcm properties.</returns> | ||
public static IDictionary<TestPlatformObjectModel.TestProperty, object> GetTcmProperties(TestPlatformObjectModel.TestCase testCase) | ||
{ | ||
var tcmProperties = new Dictionary<TestPlatformObjectModel.TestProperty, object>(); | ||
|
||
// Return empty proeprties when testCase is null or when test case id is zero. | ||
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 commentThe 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 commentThe 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. |
||
} | ||
|
||
// Step 1: Add common properties. | ||
tcmProperties[Constants.TestRunIdProperty] = testCase.GetPropertyValue<int>(Constants.TestRunIdProperty, default(int)); | ||
tcmProperties[Constants.TestPlanIdProperty] = testCase.GetPropertyValue<int>(Constants.TestPlanIdProperty, default(int)); | ||
tcmProperties[Constants.BuildConfigurationIdProperty] = testCase.GetPropertyValue<int>(Constants.BuildConfigurationIdProperty, default(int)); | ||
tcmProperties[Constants.BuildDirectoryProperty] = testCase.GetPropertyValue<string>(Constants.BuildDirectoryProperty, default(string)); | ||
tcmProperties[Constants.BuildFlavorProperty] = testCase.GetPropertyValue<string>(Constants.BuildFlavorProperty, default(string)); | ||
tcmProperties[Constants.BuildNumberProperty] = testCase.GetPropertyValue<string>(Constants.BuildNumberProperty, default(string)); | ||
tcmProperties[Constants.BuildPlatformProperty] = testCase.GetPropertyValue<string>(Constants.BuildPlatformProperty, default(string)); | ||
tcmProperties[Constants.BuildUriProperty] = testCase.GetPropertyValue<string>(Constants.BuildUriProperty, default(string)); | ||
tcmProperties[Constants.TfsServerCollectionUrlProperty] = testCase.GetPropertyValue<string>(Constants.TfsServerCollectionUrlProperty, default(string)); | ||
tcmProperties[Constants.TfsTeamProjectProperty] = testCase.GetPropertyValue<string>(Constants.TfsTeamProjectProperty, default(string)); | ||
tcmProperties[Constants.IsInLabEnvironmentProperty] = testCase.GetPropertyValue<bool>(Constants.IsInLabEnvironmentProperty, default(bool)); | ||
|
||
// Step 2: Add test case specific properties. | ||
tcmProperties[Constants.TestCaseIdProperty] = testCase.GetPropertyValue<int>(Constants.TestCaseIdProperty, default(int)); | ||
tcmProperties[Constants.TestConfigurationIdProperty] = testCase.GetPropertyValue<int>(Constants.TestConfigurationIdProperty, default(int)); | ||
tcmProperties[Constants.TestConfigurationNameProperty] = testCase.GetPropertyValue<string>(Constants.TestConfigurationNameProperty, default(string)); | ||
tcmProperties[Constants.TestPointIdProperty] = testCase.GetPropertyValue<int>(Constants.TestPointIdProperty, default(int)); | ||
|
||
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.
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