|
1 | 1 | <Project>
|
| 2 | + <Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" /> |
| 3 | + |
2 | 4 | <PropertyGroup>
|
3 | 5 | <IsPackable>false</IsPackable>
|
4 | 6 | <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
5 | 7 | </PropertyGroup>
|
6 | 8 |
|
| 9 | + <!-- .NET 9 or later run tests per TargetFramework 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")]`. --> |
7 | 11 | <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 | 12 | <TestTfmsInParallel>false</TestTfmsInParallel>
|
13 | 13 | </PropertyGroup>
|
14 | 14 |
|
15 |
| - <Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" /> |
| 15 | + <!-- Configure `Microsoft.Testing.Platform` mode behaviors (https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-integration-dotnet-test)--> |
| 16 | + <PropertyGroup> |
| 17 | + <!-- Enable `Microsoft.Testing.Platform` mode for `dotnet test` --> |
| 18 | + <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport> |
16 | 19 |
|
17 |
| - <ItemGroup> |
18 |
| - <None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" /> |
19 |
| - </ItemGroup> |
| 20 | + <!-- Show failure per test --> |
| 21 | + <TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure> |
20 | 22 |
|
| 23 | + <!-- Show complete platform output --> |
| 24 | + <TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput> |
| 25 | + |
| 26 | + <!-- Use `Microsoft.Testing.Platform` entrypoint. --> |
| 27 | + <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner> |
| 28 | + |
| 29 | + <!-- Show xUnit.net headers and information --> |
| 30 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --xunit-info</TestingPlatformCommandLineArguments> |
| 31 | + |
| 32 | + <!-- Change TestResults output directory. And enable detailed log outputs --> |
| 33 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --results-directory "$(MSBuildThisFileDirectory)TestResults"</TestingPlatformCommandLineArguments> |
| 34 | + |
| 35 | + <!-- Ignore exit code 8 (the test session run zero tests) --> |
| 36 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --ignore-exit-code 8</TestingPlatformCommandLineArguments> |
| 37 | + |
| 38 | + <!-- Enable output for passed tests --> |
| 39 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --output Detailed</TestingPlatformCommandLineArguments> |
| 40 | + </PropertyGroup> |
| 41 | + |
| 42 | + <!-- Settings for CI environment --> |
| 43 | + <PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true' AND '$(PERCY_TOKEN)' == ''"> |
| 44 | + <!-- Disable progress reports --> |
| 45 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --no-progress</TestingPlatformCommandLineArguments> |
| 46 | + |
| 47 | + <!-- Enable reporters (trx/html/ctrf ) --> |
| 48 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-xunit-trx --report-xunit-trx-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).trx</TestingPlatformCommandLineArguments> |
| 49 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-xunit-html --report-xunit-html-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).html</TestingPlatformCommandLineArguments> |
| 50 | + <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-ctrf --report-ctrf-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).ctrf</TestingPlatformCommandLineArguments> |
| 51 | + </PropertyGroup> |
| 52 | + |
| 53 | + <!-- Settings for VSTest mode. These settings will be removed in future. --> |
21 | 54 | <PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true' AND '$(PERCY_TOKEN)' == ''">
|
| 55 | + <!-- See: https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-vs-vstest#communication-protocol-preview --> |
22 | 56 | <VSTestResultsDirectory>$(MSBuildThisFileDirectory)TestResults</VSTestResultsDirectory>
|
23 | 57 | <VSTestLogger>$(VSTestLogger);trx%3BLogFileName=TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).trx</VSTestLogger>
|
24 | 58 | <VSTestLogger>$(VSTestLogger);html%3BLogFileName=TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).html</VSTestLogger>
|
25 | 59 | </PropertyGroup>
|
26 | 60 |
|
| 61 | + <!-- Add [assembly:CaptureConsole] attribute to assemblies --> |
| 62 | + <ItemGroup> |
| 63 | + <AssemblyAttribute Include="Xunit.CaptureConsole" /> |
| 64 | + </ItemGroup> |
| 65 | + |
| 66 | + <ItemGroup> |
| 67 | + <None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" /> |
| 68 | + <None Include="$(MSBuildThisFileDirectory)xunit.runner.json" CopyToOutputDirectory="PreserveNewest" /> |
| 69 | + </ItemGroup> |
| 70 | + |
27 | 71 | <ItemGroup>
|
28 | 72 | <PackageReference Include="FluentAssertions" />
|
29 | 73 | <PackageReference Include="Microsoft.NET.Test.Sdk" />
|
30 |
| - <PackageReference Include="xunit.runner.visualstudio" /> |
31 |
| - <PackageReference Include="xunit" /> |
| 74 | + <PackageReference Include="xunit.runner.visualstudio"> |
| 75 | + <PrivateAssets>all</PrivateAssets> |
| 76 | + <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> |
| 77 | + </PackageReference> |
| 78 | + <PackageReference Include="xunit.v3" /> |
32 | 79 | </ItemGroup>
|
33 | 80 | </Project>
|
0 commit comments