Skip to content

Commit e924c3c

Browse files
authored
Populated RunConfiguration Settings for RunAll. (#208)
* Populated RunConfiguration Settings for RunAll. * Added tests for DesignMode setting in run configuration. * Updated name of test.
1 parent 6933f0b commit e924c3c

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/Adapter/MSTest.CoreAdapter/MSTestExecutor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrame
7676

7777
// Populate the runsettings.
7878
MSTestSettings.PopulateSettings(runContext);
79+
RunConfigurationSettings.PopulateSettings(runContext);
7980

8081
// Scenarios that include testsettings or forcing a run via the legacy adapter are currently not supported in MSTestAdapter.
8182
if (MSTestSettings.IsLegacyScenario(frameworkHandle))

test/UnitTests/MSTest.CoreAdapter.Unit.Tests/MSTestExecutorTests.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ public void RunTestsWithSourcesShouldNotExecuteTestsIfTestSettingsIsGiven()
7575
{
7676
var sources = new List<string> { Assembly.GetExecutingAssembly().Location };
7777
string runSettingxml =
78-
@"<RunSettings>
78+
@"<RunSettings>
7979
<MSTest>
8080
<SettingsFile>DummyPath\\TestSettings1.testsettings</SettingsFile>
8181
<ForcedLegacyMode>true</ForcedLegacyMode>
82-
<IgnoreTestImpact>true</IgnoreTestImpact>
82+
<IgnoreTestImpact>true</IgnoreTestImpact>
8383
</MSTest>
8484
</RunSettings>";
8585
this.mockRunContext.Setup(dc => dc.RunSettings).Returns(this.mockRunSettings.Object);
@@ -89,5 +89,36 @@ public void RunTestsWithSourcesShouldNotExecuteTestsIfTestSettingsIsGiven()
8989
// Test should not start if TestSettings is given.
9090
this.mockFrameworkHandle.Verify(fh => fh.RecordStart(It.IsAny<TestCase>()), Times.Never);
9191
}
92+
93+
[TestMethod]
94+
public void RunTestsWithSourcesShouldSetDefaultDesignModeAsTrue()
95+
{
96+
var sources = new List<string> { Assembly.GetExecutingAssembly().Location };
97+
string runSettingxml =
98+
@"<RunSettings>
99+
</RunSettings>";
100+
this.mockRunContext.Setup(dc => dc.RunSettings).Returns(this.mockRunSettings.Object);
101+
this.mockRunSettings.Setup(rs => rs.SettingsXml).Returns(runSettingxml);
102+
this.mstestExecutor.RunTests(sources, this.mockRunContext.Object, this.mockFrameworkHandle.Object);
103+
104+
Assert.IsTrue(RunConfigurationSettings.ConfigurationSettings.DesignMode);
105+
}
106+
107+
[TestMethod]
108+
public void RunTestsWithSourcesShouldSetDesignModeAsFalseIfSpecifiedInRunSettings()
109+
{
110+
var sources = new List<string> { Assembly.GetExecutingAssembly().Location };
111+
string runSettingxml =
112+
@"<RunSettings>
113+
<RunConfiguration>
114+
<DesignMode>false</DesignMode>
115+
</RunConfiguration>
116+
</RunSettings>";
117+
this.mockRunContext.Setup(dc => dc.RunSettings).Returns(this.mockRunSettings.Object);
118+
this.mockRunSettings.Setup(rs => rs.SettingsXml).Returns(runSettingxml);
119+
this.mstestExecutor.RunTests(sources, this.mockRunContext.Object, this.mockFrameworkHandle.Object);
120+
121+
Assert.IsFalse(RunConfigurationSettings.ConfigurationSettings.DesignMode);
122+
}
92123
}
93124
}

0 commit comments

Comments
 (0)