diff --git a/src/Adapter/MSTest.CoreAdapter/Constants.cs b/src/Adapter/MSTest.CoreAdapter/Constants.cs
index 2e91aa4f81..58bde36910 100644
--- a/src/Adapter/MSTest.CoreAdapter/Constants.cs
+++ b/src/Adapter/MSTest.CoreAdapter/Constants.cs
@@ -50,6 +50,36 @@ internal static class Constants
internal static readonly TestProperty InnerResultsCountProperty = TestProperty.Register("InnerResultsCount", InnerResultsCountLabel, typeof(int), TestPropertyAttributes.Hidden, typeof(TestResult));
+ internal static readonly TestProperty TestRunIdProperty = TestProperty.Register(TestRunId, TestRunId, typeof(int), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty TestPlanIdProperty = TestProperty.Register(TestPlanId, TestPlanId, typeof(int), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty TestCaseIdProperty = TestProperty.Register(TestCaseId, TestCaseId, typeof(int), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty TestPointIdProperty = TestProperty.Register(TestPointId, TestPointId, typeof(int), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty TestConfigurationIdProperty = TestProperty.Register(TestConfigurationId, TestConfigurationId, typeof(int), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty TestConfigurationNameProperty = TestProperty.Register(TestConfigurationName, TestConfigurationName, typeof(string), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty IsInLabEnvironmentProperty = TestProperty.Register(IsInLabEnvironment, IsInLabEnvironment, typeof(bool), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty BuildConfigurationIdProperty = TestProperty.Register(BuildConfigurationId, BuildConfigurationId, typeof(int), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty BuildDirectoryProperty = TestProperty.Register(BuildDirectory, BuildDirectory, typeof(string), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty BuildFlavorProperty = TestProperty.Register(BuildFlavor, BuildFlavor, typeof(string), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty BuildNumberProperty = TestProperty.Register(BuildNumber, BuildNumber, typeof(string), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty BuildPlatformProperty = TestProperty.Register(BuildPlatform, BuildPlatform, typeof(string), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty BuildUriProperty = TestProperty.Register(BuildUri, BuildUri, typeof(string), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty TfsServerCollectionUrlProperty = TestProperty.Register(TfsServerCollectionUrl, TfsServerCollectionUrl, typeof(string), TestPropertyAttributes.Hidden, typeof(TestCase));
+
+ internal static readonly TestProperty TfsTeamProjectProperty = TestProperty.Register(TfsTeamProject, TfsTeamProject, typeof(string), TestPropertyAttributes.Hidden, typeof(TestCase));
+
#endregion
#region Private Constants
@@ -69,6 +99,22 @@ internal static class Constants
private const string ParentExecIdLabel = "ParentExecId";
private const string InnerResultsCountLabel = "InnerResultsCount";
+ private const string TestRunId = "__Tfs_TestRunId__";
+ private const string TestPlanId = "__Tfs_TestPlanId__";
+ private const string TestCaseId = "__Tfs_TestCaseId__";
+ private const string TestPointId = "__Tfs_TestPointId__";
+ private const string TestConfigurationId = "__Tfs_TestConfigurationId__";
+ private const string TestConfigurationName = "__Tfs_TestConfigurationName__";
+ private const string IsInLabEnvironment = "__Tfs_IsInLabEnvironment__";
+ private const string BuildConfigurationId = "__Tfs_BuildConfigurationId__";
+ private const string BuildDirectory = "__Tfs_BuildDirectory__";
+ private const string BuildFlavor = "__Tfs_BuildFlavor__";
+ private const string BuildNumber = "__Tfs_BuildNumber__";
+ private const string BuildPlatform = "__Tfs_BuildPlatform__";
+ private const string BuildUri = "__Tfs_BuildUri__";
+ private const string TfsServerCollectionUrl = "__Tfs_TfsServerCollectionUrl__";
+ private const string TfsTeamProject = "__Tfs_TeamProject__";
+
#endregion
}
}
diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TcmTestPropertiesProvider.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TcmTestPropertiesProvider.cs
new file mode 100644
index 0000000000..7973da7a8c
--- /dev/null
+++ b/src/Adapter/MSTest.CoreAdapter/Execution/TcmTestPropertiesProvider.cs
@@ -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;
+
+ ///
+ /// Reads and parses the TcmTestProperties in order to populate them in TestRunParameters.
+ ///
+ internal static class TcmTestPropertiesProvider
+ {
+ ///
+ /// Gets tcm properties from test case.
+ ///
+ /// Test case.
+ /// Tcm properties.
+ public static IDictionary GetTcmProperties(TestPlatformObjectModel.TestCase testCase)
+ {
+ var tcmProperties = new Dictionary();
+
+ // Return empty properties when testCase is null or when test case id is zero.
+ if (testCase == null ||
+ testCase.GetPropertyValue(Constants.TestCaseIdProperty, default(int)) == 0)
+ {
+ return tcmProperties;
+ }
+
+ // Step 1: Add common properties.
+ tcmProperties[Constants.TestRunIdProperty] = testCase.GetPropertyValue(Constants.TestRunIdProperty, default(int));
+ tcmProperties[Constants.TestPlanIdProperty] = testCase.GetPropertyValue(Constants.TestPlanIdProperty, default(int));
+ tcmProperties[Constants.BuildConfigurationIdProperty] = testCase.GetPropertyValue(Constants.BuildConfigurationIdProperty, default(int));
+ tcmProperties[Constants.BuildDirectoryProperty] = testCase.GetPropertyValue(Constants.BuildDirectoryProperty, default(string));
+ tcmProperties[Constants.BuildFlavorProperty] = testCase.GetPropertyValue(Constants.BuildFlavorProperty, default(string));
+ tcmProperties[Constants.BuildNumberProperty] = testCase.GetPropertyValue(Constants.BuildNumberProperty, default(string));
+ tcmProperties[Constants.BuildPlatformProperty] = testCase.GetPropertyValue(Constants.BuildPlatformProperty, default(string));
+ tcmProperties[Constants.BuildUriProperty] = testCase.GetPropertyValue(Constants.BuildUriProperty, default(string));
+ tcmProperties[Constants.TfsServerCollectionUrlProperty] = testCase.GetPropertyValue(Constants.TfsServerCollectionUrlProperty, default(string));
+ tcmProperties[Constants.TfsTeamProjectProperty] = testCase.GetPropertyValue(Constants.TfsTeamProjectProperty, default(string));
+ tcmProperties[Constants.IsInLabEnvironmentProperty] = testCase.GetPropertyValue(Constants.IsInLabEnvironmentProperty, default(bool));
+
+ // Step 2: Add test case specific properties.
+ tcmProperties[Constants.TestCaseIdProperty] = testCase.GetPropertyValue(Constants.TestCaseIdProperty, default(int));
+ tcmProperties[Constants.TestConfigurationIdProperty] = testCase.GetPropertyValue(Constants.TestConfigurationIdProperty, default(int));
+ tcmProperties[Constants.TestConfigurationNameProperty] = testCase.GetPropertyValue(Constants.TestConfigurationNameProperty, default(string));
+ tcmProperties[Constants.TestPointIdProperty] = testCase.GetPropertyValue(Constants.TestPointIdProperty, default(int));
+
+ return tcmProperties;
+ }
+ }
+}
diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs
index c62710a013..2fd1b39333 100644
--- a/src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs
+++ b/src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs
@@ -371,7 +371,10 @@ private void ExecuteTestsWithTestRunner(
"Executing test {0}",
unitTestElement.TestMethod.Name);
- var unitTestResult = testRunner.RunSingleTest(unitTestElement.TestMethod, sourceLevelParameters);
+ // Run single test passing test context properties to it.
+ var tcmProperties = TcmTestPropertiesProvider.GetTcmProperties(currentTest);
+ var testContextProperties = this.GetTestContextProperties(tcmProperties, sourceLevelParameters);
+ var unitTestResult = testRunner.RunSingleTest(unitTestElement.TestMethod, testContextProperties);
PlatformServiceProvider.Instance.AdapterTraceLogger.LogInfo(
"Executed test {0}",
@@ -383,6 +386,31 @@ private void ExecuteTestsWithTestRunner(
}
}
+ ///
+ /// Get test context properties.
+ ///
+ /// Tcm properties.
+ /// Source level parameters.
+ /// Test context properties.
+ private IDictionary GetTestContextProperties(IDictionary tcmProperties, IDictionary sourceLevelParameters)
+ {
+ var testContextProperties = new Dictionary();
+
+ // Add tcm properties.
+ foreach (var propertyPair in tcmProperties)
+ {
+ testContextProperties[propertyPair.Key.Id] = propertyPair.Value;
+ }
+
+ // Add source level parameters.
+ foreach (var propertyPair in sourceLevelParameters)
+ {
+ testContextProperties[propertyPair.Key] = propertyPair.Value;
+ }
+
+ return testContextProperties;
+ }
+
private void RunCleanup(
ITestExecutionRecorder testExecutionRecorder,
UnitTestRunner testRunner)
diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/UnitTestRunner.cs b/src/Adapter/MSTest.CoreAdapter/Execution/UnitTestRunner.cs
index 25896735ea..679d5a8971 100644
--- a/src/Adapter/MSTest.CoreAdapter/Execution/UnitTestRunner.cs
+++ b/src/Adapter/MSTest.CoreAdapter/Execution/UnitTestRunner.cs
@@ -62,9 +62,9 @@ public override object InitializeLifetimeService()
/// Runs a single test.
///
/// The test Method.
- /// The test Run Parameters.
+ /// The test context properties.
/// The .
- internal UnitTestResult[] RunSingleTest(TestMethod testMethod, IDictionary testRunParameters)
+ internal UnitTestResult[] RunSingleTest(TestMethod testMethod, IDictionary testContextProperties)
{
if (testMethod == null)
{
@@ -75,7 +75,7 @@ internal UnitTestResult[] RunSingleTest(TestMethod testMethod, IDictionary(testRunParameters);
+ var properties = new Dictionary(testContextProperties);
var testContext = PlatformServiceProvider.Instance.GetTestContext(testMethod, writer, properties);
testContext.SetOutcome(TestTools.UnitTesting.UnitTestOutcome.InProgress);
diff --git a/src/Adapter/MSTest.CoreAdapter/MSTest.CoreAdapter.csproj b/src/Adapter/MSTest.CoreAdapter/MSTest.CoreAdapter.csproj
index c1995f15fc..33567b9e2f 100644
--- a/src/Adapter/MSTest.CoreAdapter/MSTest.CoreAdapter.csproj
+++ b/src/Adapter/MSTest.CoreAdapter/MSTest.CoreAdapter.csproj
@@ -34,6 +34,7 @@
+
diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TcmTestPropertiesProviderTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TcmTestPropertiesProviderTests.cs
new file mode 100644
index 0000000000..5846b52563
--- /dev/null
+++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TcmTestPropertiesProviderTests.cs
@@ -0,0 +1,178 @@
+// 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.MSTestAdapter.UnitTests.Execution
+{
+ extern alias FrameworkV1;
+ extern alias FrameworkV2;
+ extern alias FrameworkV2CoreExtension;
+
+ using System;
+ using System.Collections.Generic;
+ using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution;
+ using Microsoft.VisualStudio.TestPlatform.ObjectModel;
+
+ using Assert = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
+ using TestAdapterConstants = Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Constants;
+ using TestClass = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
+ using TestMethod = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
+
+ [TestClass]
+ public class TcmTestPropertiesProviderTests
+ {
+ private TestProperty[] tcmKnownProperties = new TestProperty[]
+ {
+ TestAdapterConstants.TestRunIdProperty,
+ TestAdapterConstants.TestPlanIdProperty,
+ TestAdapterConstants.BuildConfigurationIdProperty,
+ TestAdapterConstants.BuildDirectoryProperty,
+ TestAdapterConstants.BuildFlavorProperty,
+ TestAdapterConstants.BuildNumberProperty,
+ TestAdapterConstants.BuildPlatformProperty,
+ TestAdapterConstants.BuildUriProperty,
+ TestAdapterConstants.TfsServerCollectionUrlProperty,
+ TestAdapterConstants.TfsTeamProjectProperty,
+ TestAdapterConstants.IsInLabEnvironmentProperty,
+ TestAdapterConstants.TestCaseIdProperty,
+ TestAdapterConstants.TestConfigurationIdProperty,
+ TestAdapterConstants.TestConfigurationNameProperty,
+ TestAdapterConstants.TestPointIdProperty
+ };
+
+ [TestMethod]
+ public void GetTcmPropertiesShouldReturnEmptyDictionaryIfTestCaseIsNull()
+ {
+ var tcmProperties = TcmTestPropertiesProvider.GetTcmProperties(null);
+ Assert.AreEqual(0, tcmProperties.Count);
+ }
+
+ [TestMethod]
+ 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://sampleBuildUri/",
+ "http://samplecollectionuri/", "sample team project", false,
+ 0, 54, "sample configuration name", 345
+ };
+ this.SetTestCaseProperties(testCase, propertiesValue);
+
+ var tcmProperties = TcmTestPropertiesProvider.GetTcmProperties(testCase);
+ Assert.AreEqual(0, tcmProperties.Count);
+ }
+
+ [TestMethod]
+ public void GetTcmPropertiesShouldGetAllPropertiesFromTestCase()
+ {
+ 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://sampleBuildUri/",
+ "http://samplecollectionuri/", "sample team project", false,
+ 1401, 54, "sample configuration name", 345
+ };
+ this.SetTestCaseProperties(testCase, propertiesValue);
+
+ var tcmProperties = TcmTestPropertiesProvider.GetTcmProperties(testCase);
+
+ this.VerifyTcmProperties(tcmProperties, testCase);
+ }
+
+ [TestMethod]
+ public void GetTcmPropertiesShouldCopyMultiplePropertiesCorrectlyFromTestCase()
+ {
+ // Verify 1st call.
+ var testCase1 = new TestCase("PassingTestFomTestCase", new Uri("http://sampleUri/"), "unittestproject1.dll");
+ var propertiesValue1 = new object[]
+ {
+ 32, 534, 5, "sample build directory", "sample build flavor",
+ "132456", "sample build platform", "http://sampleBuildUri/",
+ "http://samplecollectionuri/", "sample team project", false,
+ 1401, 54, "sample configuration name", 345
+ };
+ this.SetTestCaseProperties(testCase1, propertiesValue1);
+ var tcmProperties1 = TcmTestPropertiesProvider.GetTcmProperties(testCase1);
+ this.VerifyTcmProperties(tcmProperties1, testCase1);
+
+ // Verify 2nd call.
+ var testCase2 = new TestCase("PassingTestFomTestCase2", new Uri("http://sampleUri2/"), "unittestproject2.dll");
+ var propertiesValue2 = new object[]
+ {
+ 33, 535, 6, "sample build directory 2", "sample build flavor 2",
+ "132457", "sample build platform 2", "http://sampleBuildUri2/",
+ "http://samplecollectionuri2/", "sample team project", true,
+ 1403, 55, "sample configuration name 2", 346
+ };
+ this.SetTestCaseProperties(testCase2, propertiesValue2);
+ var tcmProperties2 = TcmTestPropertiesProvider.GetTcmProperties(testCase2);
+ this.VerifyTcmProperties(tcmProperties2, testCase2);
+ }
+
+ [TestMethod]
+ public void GetTcmPropertiesShouldHandleDuplicateTestsProperlyFromTestCase()
+ {
+ // Verify 1st call.
+ var testCase1 = new TestCase("PassingTestFomTestCase", new Uri("http://sampleUri/"), "unittestproject1.dll");
+ var propertiesValue1 = new object[]
+ {
+ 32, 534, 5, "sample build directory", "sample build flavor",
+ "132456", "sample build platform", "http://sampleBuildUri/",
+ "http://samplecollectionuri/", "sample team project", false,
+ 1401, 54, "sample configuration name", 345
+ };
+ this.SetTestCaseProperties(testCase1, propertiesValue1);
+ var tcmProperties1 = TcmTestPropertiesProvider.GetTcmProperties(testCase1);
+ this.VerifyTcmProperties(tcmProperties1, testCase1);
+
+ // Verify 2nd call.
+ var testCase2 = new TestCase("PassingTestFomTestCase", new Uri("http://sampleUri/"), "unittestproject1.dll");
+ var propertiesValue2 = new object[]
+ {
+ 33, 535, 6, "sample build directory 2", "sample build flavor 2",
+ "132457", "sample build platform 2", "http://sampleBuildUri2/",
+ "http://samplecollectionuri2/", "sample team project", true,
+ 1403, 55, "sample configuration name 2", 346
+ };
+ this.SetTestCaseProperties(testCase2, propertiesValue2);
+ var tcmProperties2 = TcmTestPropertiesProvider.GetTcmProperties(testCase2);
+ this.VerifyTcmProperties(tcmProperties2, testCase2);
+
+ // Verify 3rd call.
+ var testCase3 = new TestCase("PassingTestFomTestCase2", new Uri("http://sampleUri/"), "unittestproject2.dll");
+ var propertiesValue3 = new object[]
+ {
+ 34, 536, 7, "sample build directory 3", "sample build flavor 3",
+ "132458", "sample build platform 3", "http://sampleBuildUri3/",
+ "http://samplecollectionuri3/", "sample team project2", true,
+ 1404, 55, "sample configuration name 3", 347
+ };
+ this.SetTestCaseProperties(testCase3, propertiesValue3);
+ var tcmProperties3 = TcmTestPropertiesProvider.GetTcmProperties(testCase3);
+ this.VerifyTcmProperties(tcmProperties3, testCase3);
+ }
+
+ private void SetTestCaseProperties(TestCase testCase, object[] propertiesValue)
+ {
+ var tcmKnownPropertiesEnumerator = this.tcmKnownProperties.GetEnumerator();
+
+ var propertiesValueEnumerator = propertiesValue.GetEnumerator();
+ while (tcmKnownPropertiesEnumerator.MoveNext() && propertiesValueEnumerator.MoveNext())
+ {
+ var property = tcmKnownPropertiesEnumerator.Current;
+ var value = propertiesValueEnumerator.Current;
+ testCase.SetPropertyValue(property as TestProperty, value);
+ }
+ }
+
+ private void VerifyTcmProperties(IDictionary tcmProperties, TestCase testCase)
+ {
+ foreach (var property in this.tcmKnownProperties)
+ {
+ Assert.AreEqual(testCase.GetPropertyValue(property), tcmProperties[property]);
+ }
+ }
+ }
+}
diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs
index 8ee147fd90..b4964a2aa9 100644
--- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs
+++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs
@@ -27,6 +27,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution
using CollectionAssert = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.CollectionAssert;
using Ignore = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.IgnoreAttribute;
using StringAssert = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.StringAssert;
+ using TestAdapterConstants = Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Constants;
using TestClass = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using TestCleanup = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.TestCleanupAttribute;
using TestInitialize = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.TestInitializeAttribute;
@@ -48,6 +49,25 @@ public class TestExecutionManagerTests
private TestExecutionManager TestExecutionManager { get; set; }
+ private TestProperty[] tcmKnownProperties = new TestProperty[]
+ {
+ TestAdapterConstants.TestRunIdProperty,
+ TestAdapterConstants.TestPlanIdProperty,
+ TestAdapterConstants.BuildConfigurationIdProperty,
+ TestAdapterConstants.BuildDirectoryProperty,
+ TestAdapterConstants.BuildFlavorProperty,
+ TestAdapterConstants.BuildNumberProperty,
+ TestAdapterConstants.BuildPlatformProperty,
+ TestAdapterConstants.BuildUriProperty,
+ TestAdapterConstants.TfsServerCollectionUrlProperty,
+ TestAdapterConstants.TfsTeamProjectProperty,
+ TestAdapterConstants.IsInLabEnvironmentProperty,
+ TestAdapterConstants.TestCaseIdProperty,
+ TestAdapterConstants.TestConfigurationIdProperty,
+ TestAdapterConstants.TestConfigurationNameProperty,
+ TestAdapterConstants.TestPointIdProperty
+ };
+
[TestInitialize]
public void TestInit()
{
@@ -280,6 +300,20 @@ public void RunTestsForTestShouldPassInTestRunParametersInformationAsPropertiesT
new KeyValuePair("webAppUrl", "http://localhost"));
}
+ [TestMethodV1]
+ public void RunTestsForTestShouldPassInTcmPropertiesAsPropertiesToTheTest()
+ {
+ var testCase = this.GetTestCase(typeof(DummyTestClass), "PassingTest");
+ 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, 1401, 54, "sample configuration name", 345 };
+ this.SetTestCaseProperties(testCase, propertiesValue);
+
+ TestCase[] tests = new[] { testCase };
+
+ this.TestExecutionManager.RunTests(tests, this.runContext, this.frameworkHandle, new TestRunCancellationToken());
+
+ this.VerifyTcmProperties(DummyTestClass.TestContextProperties, testCase);
+ }
+
[TestMethodV1]
public void RunTestsForTestShouldPassInDeploymentInformationAsPropertiesToTheTest()
{
@@ -806,6 +840,27 @@ private void SetCaller(string caller)
this.callers.Add(caller);
}
+ private void VerifyTcmProperties(IDictionary tcmProperties, TestCase testCase)
+ {
+ foreach (var property in this.tcmKnownProperties)
+ {
+ Assert.AreEqual(testCase.GetPropertyValue(property), tcmProperties[property.Id]);
+ }
+ }
+
+ private void SetTestCaseProperties(TestCase testCase, object[] propertiesValue)
+ {
+ var tcmKnownPropertiesEnumerator = this.tcmKnownProperties.GetEnumerator();
+
+ var propertiesValueEnumerator = propertiesValue.GetEnumerator();
+ while (tcmKnownPropertiesEnumerator.MoveNext() && propertiesValueEnumerator.MoveNext())
+ {
+ var property = tcmKnownPropertiesEnumerator.Current;
+ var value = propertiesValueEnumerator.Current;
+ testCase.SetPropertyValue(property as TestProperty, value);
+ }
+ }
+
#endregion
#region Dummy implementation
diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/MSTest.CoreAdapter.Unit.Tests.csproj b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/MSTest.CoreAdapter.Unit.Tests.csproj
index 5c7854a9c4..fb289533c4 100644
--- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/MSTest.CoreAdapter.Unit.Tests.csproj
+++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/MSTest.CoreAdapter.Unit.Tests.csproj
@@ -67,6 +67,7 @@
+