Skip to content

Commit bcf3943

Browse files
authored
Update MSTest templates to v4 (#50182)
2 parents e14d0e3 + 99dd9d0 commit bcf3943

File tree

5 files changed

+22
-55
lines changed

5 files changed

+22
-55
lines changed

template_feed/Microsoft.DotNet.Common.ProjectTemplates.10.0/content/MSTest-CSharp/Company.TestProject1.csproj

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--#if (UseMSTestSdk)-->
2-
<Project Sdk="MSTest.Sdk/3.10.0">
2+
<Project Sdk="MSTest.Sdk/4.0.0-preview.25415.9">
33

44
<PropertyGroup>
55
<TargetFramework Condition="'$(TargetFrameworkOverride)' == ''">net10.0</TargetFramework>
@@ -18,11 +18,6 @@
1818
</ItemGroup>
1919
<!--#endif-->
2020
<!--#else-->
21-
<!--
22-
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
23-
For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test
24-
-->
25-
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
2621
<TestingExtensionsProfile Condition=" '$(ExtensionsProfile)' != 'Default' ">$(ExtensionsProfile)</TestingExtensionsProfile>
2722
</PropertyGroup>
2823
<!--#endif-->
@@ -41,20 +36,14 @@
4136
<!--#if (TestRunner == "Microsoft.Testing.Platform")-->
4237
<EnableMSTestRunner>true</EnableMSTestRunner>
4338
<OutputType>Exe</OutputType>
44-
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
45-
<!--
46-
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
47-
For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test
48-
-->
49-
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
5039
<!--#endif-->
5140
</PropertyGroup>
5241

5342
<ItemGroup>
5443
<!--#if (CoverageTool == "coverlet")-->
5544
<PackageReference Include="coverlet.collector" Version="6.0.4" />
5645
<!--#endif-->
57-
<PackageReference Include="MSTest" Version="3.10.0" />
46+
<PackageReference Include="MSTest" Version="4.0.0-preview.25415.9" />
5847
</ItemGroup>
5948

6049
<ItemGroup>

template_feed/Microsoft.DotNet.Common.ProjectTemplates.10.0/content/MSTest-FSharp/Company.TestProject1.fsproj

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--#if (UseMSTestSdk)-->
2-
<Project Sdk="MSTest.Sdk/3.10.0">
2+
<Project Sdk="MSTest.Sdk/4.0.0-preview.25415.9">
33

44
<PropertyGroup>
55
<TargetFramework Condition="'$(TargetFrameworkOverride)' == ''">net10.0</TargetFramework>
@@ -18,11 +18,6 @@
1818
</ItemGroup>
1919
<!--#endif-->
2020
<!--#else-->
21-
<!--
22-
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
23-
For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test
24-
-->
25-
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
2621
<TestingExtensionsProfile Condition=" '$(ExtensionsProfile)' != 'Default' ">$(ExtensionsProfile)</TestingExtensionsProfile>
2722
</PropertyGroup>
2823
<!--#endif-->
@@ -46,20 +41,14 @@
4641
<!--#if (TestRunner == "Microsoft.Testing.Platform")-->
4742
<EnableMSTestRunner>true</EnableMSTestRunner>
4843
<OutputType>Exe</OutputType>
49-
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
50-
<!--
51-
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
52-
For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test
53-
-->
54-
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
5544
<!--#endif-->
5645
</PropertyGroup>
5746

5847
<ItemGroup>
5948
<!--#if (CoverageTool == "coverlet")-->
6049
<PackageReference Include="coverlet.collector" Version="6.0.4" />
6150
<!--#endif-->
62-
<PackageReference Include="MSTest" Version="3.10.0" />
51+
<PackageReference Include="MSTest" Version="4.0.0-preview.25415.9" />
6352
</ItemGroup>
6453

6554
<ItemGroup>

template_feed/Microsoft.DotNet.Common.ProjectTemplates.10.0/content/MSTest-VisualBasic/Company.TestProject1.vbproj

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--#if (UseMSTestSdk)-->
2-
<Project Sdk="MSTest.Sdk/3.10.0">
2+
<Project Sdk="MSTest.Sdk/4.0.0-preview.25415.9">
33

44
<PropertyGroup>
55
<TargetFramework Condition="'$(TargetFrameworkOverride)' == ''">net10.0</TargetFramework>
@@ -18,11 +18,6 @@
1818
</ItemGroup>
1919
<!--#endif-->
2020
<!--#else-->
21-
<!--
22-
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
23-
For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test
24-
-->
25-
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
2621
<TestingExtensionsProfile Condition=" '$(ExtensionsProfile)' != 'Default' ">$(ExtensionsProfile)</TestingExtensionsProfile>
2722
</PropertyGroup>
2823
<!--#endif-->
@@ -41,20 +36,14 @@
4136
<!--#if (TestRunner == "Microsoft.Testing.Platform")-->
4237
<EnableMSTestRunner>true</EnableMSTestRunner>
4338
<OutputType>Exe</OutputType>
44-
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
45-
<!--
46-
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
47-
For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test
48-
-->
49-
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
5039
<!--#endif-->
5140
</PropertyGroup>
5241

5342
<ItemGroup>
5443
<!--#if (CoverageTool == "coverlet")-->
5544
<PackageReference Include="coverlet.collector" Version="6.0.4" />
5645
<!--#endif-->
57-
<PackageReference Include="MSTest" Version="3.10.0" />
46+
<PackageReference Include="MSTest" Version="4.0.0-preview.25415.9" />
5847
</ItemGroup>
5948

6049
<ItemGroup>

template_feed/Microsoft.DotNet.Common.ProjectTemplates.10.0/content/Playwright-MSTest-CSharp/Company.TestProject1.csproj

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--#if (UseMSTestSdk)-->
2-
<Project Sdk="MSTest.Sdk/3.10.0">
2+
<Project Sdk="MSTest.Sdk/4.0.0-preview.25415.9">
33

44
<PropertyGroup>
55
<TargetFramework Condition="'$(TargetFrameworkOverride)' == ''">net10.0</TargetFramework>
@@ -19,11 +19,6 @@
1919
</ItemGroup>
2020
<!--#endif-->
2121
<!--#else-->
22-
<!--
23-
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
24-
For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test
25-
-->
26-
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
2722
<TestingExtensionsProfile Condition=" '$(ExtensionsProfile)' != 'Default' ">$(ExtensionsProfile)</TestingExtensionsProfile>
2823
</PropertyGroup>
2924
<!--#endif-->
@@ -42,21 +37,15 @@
4237
<!--#if (TestRunner == "Microsoft.Testing.Platform")-->
4338
<EnableMSTestRunner>true</EnableMSTestRunner>
4439
<OutputType>Exe</OutputType>
45-
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
46-
<!--
47-
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
48-
For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test
49-
-->
50-
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
5140
<!--#endif-->
5241
</PropertyGroup>
5342

5443
<ItemGroup>
5544
<!--#if (CoverageTool == "coverlet")-->
5645
<PackageReference Include="coverlet.collector" Version="6.0.4" />
5746
<!--#endif-->
58-
<PackageReference Include="Microsoft.Playwright.MSTest" Version="1.51.0" />
59-
<PackageReference Include="MSTest" Version="3.10.0" />
47+
<PackageReference Include="Microsoft.Playwright.MSTest.v4" Version="1.55.0-beta-4" />
48+
<PackageReference Include="MSTest" Version="4.0.0-preview.25415.9" />
6049
</ItemGroup>
6150

6251
<ItemGroup>

test/dotnet-new.IntegrationTests/DotnetNewTestTemplatesTests.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,25 @@ public void MSTestAndPlaywrightProjectTemplate_WithCoverageToolAndTestRunner_Can
193193

194194
if (runDotnetTest)
195195
{
196+
var isMTP = testRunner == "Microsoft.Testing.Platform";
197+
if (isMTP)
198+
{
199+
File.WriteAllText(Path.Combine(outputDirectory, "dotnet.config"), """
200+
[dotnet.test.runner]
201+
name = "Microsoft.Testing.Platform"
202+
""");
203+
}
204+
196205
var result = new DotnetTestCommand(_log, false)
197206
.WithWorkingDirectory(outputDirectory)
198-
.Execute(outputDirectory);
207+
#pragma warning disable SA1010 // Opening square brackets should be spaced correctly - false positive. Current formatting is good.
208+
.Execute(isMTP ? ["--directory", outputDirectory] : [outputDirectory]);
209+
#pragma warning restore SA1010 // Opening square brackets should be spaced correctly
199210

200211
result.Should().Pass();
201212

202213
result.StdOut.Should().Contain("Passed!");
203-
result.StdOut.Should().MatchRegex(@"Passed:\s*1");
214+
result.StdOut.Should().MatchRegex(isMTP ? "succeeded: 1" : @"Passed:\s*1");
204215
}
205216

206217
// After executing dotnet new and before cleaning up

0 commit comments

Comments
 (0)