|
1 | 1 | <Project> |
| 2 | + <Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" /> |
| 3 | + |
2 | 4 | <PropertyGroup> |
3 | 5 | <IsPackable>false</IsPackable> |
4 | 6 | <SatelliteResourceLanguages>en</SatelliteResourceLanguages> |
| 7 | + <IsTestingPlatformApplication>true</IsTestingPlatformApplication> |
| 8 | + <IsTestProject>true</IsTestProject> |
5 | 9 | </PropertyGroup> |
6 | 10 |
|
| 11 | + <!-- .NET 9 or later run tests per TargetFramework in parallel by default. |
| 12 | + It is necessary to disable this feature because there are tests that need to be executed sequentially that are marked with `[Collection("docfx STA")]`. --> |
7 | 13 | <PropertyGroup> |
8 | | - <!-- |
9 | | - .NET 9 preview 2 or later run tests in parallel by default. |
10 | | - It is necessary to disable this feature because there are tests that need to be executed sequentially that are marked with `[Collection("docfx STA")]`. |
11 | | - --> |
12 | 14 | <TestTfmsInParallel>false</TestTfmsInParallel> |
13 | 15 | </PropertyGroup> |
14 | 16 |
|
15 | | - <Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" /> |
| 17 | + <!-- Configure `Microsoft.Testing.Platform` mode behaviors (https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-integration-dotnet-test)--> |
16 | 18 |
|
17 | | - <ItemGroup> |
18 | | - <None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" /> |
19 | | - </ItemGroup> |
| 19 | + <!-- Following settings are required for .NET 9 SDK and earlier --> |
| 20 | + <PropertyGroup Condition="'$(TargetFramework)'=='net9.0' OR '$(TargetFramework)'=='net8.0'"> |
| 21 | + <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport> |
| 22 | + <TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput> |
| 23 | + <TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure> |
| 24 | + </PropertyGroup> |
| 25 | + |
| 26 | + <PropertyGroup> |
| 27 | + <!-- Use `Microsoft.Testing.Platform` entrypoint --> |
| 28 | + <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner> |
| 29 | + </PropertyGroup> |
| 30 | + |
| 31 | + <PropertyGroup> |
| 32 | + <!-- Show xUnit.net headers and information --> |
| 33 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --xunit-info</TestingPlatformCommandLineArguments> |
20 | 34 |
|
| 35 | + <!-- Change TestResults output directory. And enable detailed log outputs --> |
| 36 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --results-directory "$(MSBuildThisFileDirectory)TestResults"</TestingPlatformCommandLineArguments> |
| 37 | + |
| 38 | + <!-- Ignore exit code 8 (the test session run zero tests) --> |
| 39 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --ignore-exit-code 8</TestingPlatformCommandLineArguments> |
| 40 | + |
| 41 | + <!-- Enable output for passed tests --> |
| 42 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --output Detailed</TestingPlatformCommandLineArguments> |
| 43 | + </PropertyGroup> |
| 44 | + |
| 45 | + <!-- Settings for CI environment --> |
21 | 46 | <PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true' AND '$(PERCY_TOKEN)' == ''"> |
22 | | - <VSTestResultsDirectory>$(MSBuildThisFileDirectory)TestResults</VSTestResultsDirectory> |
23 | | - <VSTestLogger>$(VSTestLogger);trx%3BLogFileName=TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).trx</VSTestLogger> |
24 | | - <VSTestLogger>$(VSTestLogger);html%3BLogFileName=TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).html</VSTestLogger> |
| 47 | + <!-- Disable progress reports --> |
| 48 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --no-progress</TestingPlatformCommandLineArguments> |
| 49 | + |
| 50 | + <!-- Enable reporters (trx/html/ctrf ) --> |
| 51 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-xunit-trx --report-xunit-trx-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).trx</TestingPlatformCommandLineArguments> |
| 52 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-xunit-html --report-xunit-html-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).html</TestingPlatformCommandLineArguments> |
| 53 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-ctrf --report-ctrf-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).ctrf</TestingPlatformCommandLineArguments> |
25 | 54 | </PropertyGroup> |
26 | 55 |
|
27 | | - <ItemGroup Condition="'$(IsTestProject)' == 'true'"> |
| 56 | + <ItemGroup Condition="$(MSBuildProjectName.EndsWith('.Tests'))"> |
| 57 | + <!-- Set [assembly:CaptureConsole] attribute to assembly --> |
| 58 | + <AssemblyAttribute Include="Xunit.CaptureConsole" /> |
| 59 | + |
| 60 | + <!-- Add project items --> |
| 61 | + <None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" /> |
| 62 | + <None Include="$(MSBuildThisFileDirectory)xunit.runner.json" CopyToOutputDirectory="PreserveNewest" /> |
| 63 | + |
| 64 | + <!-- Add Docfx.Tests.Common` project reference to test projects --> |
28 | 65 | <ProjectReference Include="$(MSBuildThisFileDirectory)Docfx.Tests.Common/Docfx.Tests.Common.csproj" /> |
29 | | - </ItemGroup> |
30 | 66 |
|
31 | | - <ItemGroup> |
| 67 | + <!-- Add common test package references --> |
32 | 68 | <PackageReference Include="AwesomeAssertions" /> |
33 | | - <PackageReference Include="Microsoft.NET.Test.Sdk" /> |
34 | | - <PackageReference Include="xunit.runner.visualstudio" /> |
35 | | - <PackageReference Include="xunit" /> |
| 69 | + <PackageReference Include="xunit.v3.mtp-v2" /> |
36 | 70 | </ItemGroup> |
| 71 | + |
37 | 72 | </Project> |
0 commit comments