Skip to content

Commit 9b98cf5

Browse files
authored
Update xunit templates to xunit.v3 (#50117)
1 parent b656a63 commit 9b98cf5

File tree

8 files changed

+61
-17
lines changed

8 files changed

+61
-17
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,30 @@
66
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.TestProject1</RootNamespace>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>
9+
<OutputType>Exe</OutputType>
910
<IsPackable Condition="'$(EnablePack)' == 'true'">true</IsPackable>
1011
<IsPackable Condition="'$(EnablePack)' != 'true'">false</IsPackable>
12+
13+
<!-- To enable Microsoft.Testing.Platform, uncomment the following line. -->
14+
<!-- <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner> -->
15+
<!-- Note: to use Microsoft.Testing.Platform correctly with dotnet test: -->
16+
<!-- 1. You must add dotnet.config specifying the test runner to be Microsoft.Testing.Platform -->
17+
<!-- 2. You must use .NET 10 SDK or later -->
18+
<!-- For more information, see https://aka.ms/dotnet-test/mtp and https://xunit.net/docs/getting-started/v3/microsoft-testing-platform -->
19+
<!-- To enable code coverage with Microsoft.Testing.Platform, add a package reference to Microsoft.Testing.Extensions.CodeCoverage -->
20+
<!-- https://learn.microsoft.comdotnet/core/testing/microsoft-testing-platform-extensions-code-coverage -->
1121
</PropertyGroup>
1222

1323
<ItemGroup>
14-
<PackageReference Include="coverlet.collector" Version="6.0.4" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
16-
<PackageReference Include="xunit" Version="2.9.3" />
24+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
25+
<PackageReference Include="xunit.v3" Version="3.0.0" />
1726
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.3" />
1827
</ItemGroup>
1928

29+
<ItemGroup>
30+
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
31+
</ItemGroup>
32+
2033
<ItemGroup>
2134
<Using Include="Xunit" />
2235
</ItemGroup>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json"
3+
}

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,32 @@
44
<TargetFramework Condition="'$(TargetFrameworkOverride)' == ''">net10.0</TargetFramework>
55
<TargetFramework Condition="'$(TargetFrameworkOverride)' != ''">TargetFrameworkOverride</TargetFramework>
66
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.TestProject1</RootNamespace>
7+
<OutputType>Exe</OutputType>
78
<IsPackable Condition="'$(EnablePack)' == 'true'">true</IsPackable>
89
<IsPackable Condition="'$(EnablePack)' != 'true'">false</IsPackable>
9-
<GenerateProgramFile>false</GenerateProgramFile>
10+
11+
<!-- To enable Microsoft.Testing.Platform, uncomment the following line. -->
12+
<!-- <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner> -->
13+
<!-- Note: to use Microsoft.Testing.Platform correctly with dotnet test: -->
14+
<!-- 1. You must add dotnet.config specifying the test runner to be Microsoft.Testing.Platform -->
15+
<!-- 2. You must use .NET 10 SDK or later -->
16+
<!-- For more information, see https://aka.ms/dotnet-test/mtp and https://xunit.net/docs/getting-started/v3/microsoft-testing-platform -->
17+
<!-- To enable code coverage with Microsoft.Testing.Platform, add a package reference to Microsoft.Testing.Extensions.CodeCoverage -->
18+
<!-- https://learn.microsoft.comdotnet/core/testing/microsoft-testing-platform-extensions-code-coverage -->
1019
</PropertyGroup>
1120

1221
<ItemGroup>
1322
<Compile Include="Tests.fs" />
14-
<Compile Include="Program.fs" />
1523
</ItemGroup>
1624

1725
<ItemGroup>
18-
<PackageReference Include="coverlet.collector" Version="6.0.4" />
19-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
20-
<PackageReference Include="xunit" Version="2.9.3" />
26+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
27+
<PackageReference Include="xunit.v3" Version="3.0.0" />
2128
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.3" />
2229
</ItemGroup>
2330

31+
<ItemGroup>
32+
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
33+
</ItemGroup>
34+
2435
</Project>

template_feed/Microsoft.DotNet.Common.ProjectTemplates.10.0/content/XUnit-FSharp/Program.fs

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json"
3+
}

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,28 @@
44
<RootNamespace>Company.TestProject1</RootNamespace>
55
<TargetFramework Condition="'$(TargetFrameworkOverride)' == ''">net10.0</TargetFramework>
66
<TargetFramework Condition="'$(TargetFrameworkOverride)' != ''">TargetFrameworkOverride</TargetFramework>
7+
<OutputType>Exe</OutputType>
78
<IsPackable Condition="'$(EnablePack)' == 'true'">true</IsPackable>
89
<IsPackable Condition="'$(EnablePack)' != 'true'">false</IsPackable>
10+
11+
<!-- To enable Microsoft.Testing.Platform, uncomment the following line. -->
12+
<!-- <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner> -->
13+
<!-- Note: to use Microsoft.Testing.Platform correctly with dotnet test: -->
14+
<!-- 1. You must add dotnet.config specifying the test runner to be Microsoft.Testing.Platform -->
15+
<!-- 2. You must use .NET 10 SDK or later -->
16+
<!-- For more information, see https://aka.ms/dotnet-test/mtp and https://xunit.net/docs/getting-started/v3/microsoft-testing-platform -->
17+
<!-- To enable code coverage with Microsoft.Testing.Platform, add a package reference to Microsoft.Testing.Extensions.CodeCoverage -->
18+
<!-- https://learn.microsoft.comdotnet/core/testing/microsoft-testing-platform-extensions-code-coverage -->
919
</PropertyGroup>
1020

1121
<ItemGroup>
12-
<PackageReference Include="coverlet.collector" Version="6.0.4" />
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
14-
<PackageReference Include="xunit" Version="2.9.3" />
22+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
23+
<PackageReference Include="xunit.v3" Version="3.0.0" />
1524
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.3" />
1625
</ItemGroup>
1726

27+
<ItemGroup>
28+
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
29+
</ItemGroup>
30+
1831
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json"
3+
}

test/Microsoft.NET.Build.Tests/ReferenceExeTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ public void ReferencedExeCanRunWhenPublishedWithTrimming(bool referenceExeInCode
325325
[RequiresMSBuildVersionTheory("17.0.0.32901")]
326326
[CombinatorialData]
327327
public void TestProjectCanReferenceExe(
328-
[CombinatorialValues("xunit", "mstest")] string testTemplateName,
328+
// Note: xunit.v3 is always a "real" executable even with VSTest. So it's irrelevant here.
329+
[CombinatorialValues("nunit", "mstest")] string testTemplateName,
329330
bool setSelfContainedProperty)
330331
{
331332
var testConsoleProject = new TestProject("ConsoleApp")
@@ -467,7 +468,8 @@ public void MTPNonSelfContainedExecutableCannotBeReferencedBySelfContained(bool
467468
[RequiresMSBuildVersionTheory("17.0.0.32901")]
468469
[CombinatorialData]
469470
public void ExeProjectCanReferenceTestProject(
470-
[CombinatorialValues("xunit", "mstest")] string testTemplateName,
471+
// Note: xunit.v3 is always a "real" executable even with VSTest. So it's irrelevant here.
472+
[CombinatorialValues("nunit", "mstest")] string testTemplateName,
471473
bool setSelfContainedProperty,
472474
bool buildWithSelfContainedFromCommandLine)
473475
{

0 commit comments

Comments
 (0)