Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ private void CacheSessionParameters(IRunContext runContext, ITestExecutionRecord
var testRunParameters = RunSettingsUtilities.GetTestRunParameters(runContext.RunSettings.SettingsXml);
if (testRunParameters != null)
{
// Clear sessionParameters to prevent key collisions of test run parameters in case
// "Keep Test Execution Engine Alive" is selected in VS.
this.sessionParameters.Clear();
foreach (var kvp in testRunParameters)
{
this.sessionParameters.Add(kvp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,40 @@ public void RunTestsForTestShouldPassInDeploymentInformationAsPropertiesToTheTes
testablePlatformService.MockSettingsProvider.Verify(sp => sp.GetProperties(It.IsAny<string>()), Times.Once);
}

[TestMethodV1]
public void RunTestsShouldClearSessionParametersAcrossRuns()
{
var testCase = this.GetTestCase(typeof(DummyTestClass), "PassingTest");

TestCase[] tests = new[] { testCase };
this.runContext.MockRunSettings.Setup(rs => rs.SettingsXml).Returns(
@"<RunSettings>
<TestRunParameters>
<Parameter name=""webAppUrl"" value=""http://localhost"" />
<Parameter name = ""webAppUserName"" value=""Admin"" />
</TestRunParameters>
</RunSettings>");

// Trigger First Run
this.TestExecutionManager.RunTests(tests, this.runContext, this.frameworkHandle, new TestRunCancellationToken());

// Update runsettings to have different values for similar keys
this.runContext.MockRunSettings.Setup(rs => rs.SettingsXml).Returns(
@"<RunSettings>
<TestRunParameters>
<Parameter name=""webAppUrl"" value=""http://updatedLocalHost"" />
<Parameter name = ""webAppUserName"" value=""Admin"" />
</TestRunParameters>
</RunSettings>");

// Trigger another Run
this.TestExecutionManager.RunTests(tests, this.runContext, this.frameworkHandle, new TestRunCancellationToken());

CollectionAssert.Contains(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do String assert.

DummyTestClass.TestContextProperties.ToList(),
new KeyValuePair<string, object>("webAppUrl", "http://updatedLocalHost"));
}

#endregion

#region Run Tests on Sources
Expand Down