Skip to content

Commit 8546482

Browse files
committed
chore: update xunit version to v3
1 parent 739d309 commit 8546482

File tree

37 files changed

+441
-86
lines changed

37 files changed

+441
-86
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
branches: [ main, feature/*, hotfix/* ]
77
workflow_dispatch:
88

9+
env:
10+
NO_COLOR: true
11+
912
jobs:
1013
test:
1114
runs-on: ${{ matrix.os }}
@@ -31,30 +34,47 @@ jobs:
3134
shell: bash
3235
working-directory: templates
3336

34-
- run: dotnet test -c Release -f net10.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal"
37+
- name: Install Chromium headless shell
38+
shell: pwsh
39+
working-directory: src/docfx/bin/Release/net8.0
40+
run: |
41+
$env:PLAYWRIGHT_NODEJS_PATH = (Get-Command node).Path
42+
./playwright.ps1 install chromium --only-shell
43+
44+
- name: Install `dotnet-coverage` as .NET Global Tool
45+
run: dotnet tool install -g dotnet-coverage
46+
47+
- name: Start dotnet-coverage with background server mode
48+
run: dotnet coverage collect --session-id docfx_coverage --settings test/CodeCoverage.runsettings --server-mode --background
49+
50+
- run: dotnet coverage connect docfx_coverage "dotnet test -c Release -f net10.0 --no-build"
3551
id: test-net100
3652

37-
- run: dotnet test -c Release -f net9.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal"
53+
- run: dotnet coverage connect docfx_coverage "dotnet test -c Release -f net9.0 --no-build"
3854
if: matrix.os == 'ubuntu-latest'
3955
id: test-net90
4056

41-
- run: dotnet test -c Release -f net8.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal"
57+
- run: dotnet coverage connect docfx_coverage "dotnet test -c Release -f net8.0 --no-build"
4258
if: matrix.os == 'ubuntu-latest'
4359
id: test-net80
4460

4561
- run: npm i -g @percy/cli
4662
if: matrix.os == 'ubuntu-latest'
4763

48-
- run: percy exec -- dotnet test -c Release -f net10.0 --filter Stage=Percy --no-build --collect:"XPlat Code Coverage"
64+
- run: dotnet coverage connect docfx_coverage "percy exec -- dotnet test -c Release -f net10.0 --no-build -- --filter-trait "Stage=Percy""
4965
if: matrix.os == 'ubuntu-latest'
5066
env:
5167
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
5268

69+
- name: Shutdown dotnet-coverage server.
70+
run: dotnet coverage shutdown docfx_coverage --timeout 60000
71+
5372
- uses: codecov/codecov-action@v5
5473
if: matrix.os == 'ubuntu-latest'
5574
with:
5675
fail_ci_if_error: false
5776
token: ${{ secrets.CODECOV_TOKEN }}
77+
directory: test/TestResults/code-coverages
5878

5979
- run: echo "DOTNET_DbgEnableMiniDump=1" >> $GITHUB_ENV
6080
if: matrix.os == 'ubuntu-latest'
@@ -74,8 +94,10 @@ jobs:
7494
name: logs-${{ matrix.os }}
7595
path: |
7696
msbuild.binlog
97+
test/**/TestResults/*.log
7798
test/**/TestResults/*.trx
7899
test/**/TestResults/*.html
100+
test/**/TestResults/*.ctrf
79101
80102
- uses: actions/upload-artifact@v6
81103
if: ${{ failure() && matrix.os == 'ubuntu-latest' }}

global.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"test": {
3+
"runner": "Microsoft.Testing.Platform"
4+
}
5+
}

samples/Directory.Packages.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<Project>
2+
</Project>

test/CodeCoverage.runsettings

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Configuration>
3+
<!-- Available Options: https://github.com/microsoft/codecoverage/blob/main/docs/configuration.md -->
4+
<CoverageFileName>coverage.cobertura.xml</CoverageFileName>
5+
<Format>cobertura</Format>
6+
<IncludeTestAssembly>false</IncludeTestAssembly>
7+
<DeterministicReport>true</DeterministicReport>
8+
<CollectFromChildProcesses>true</CollectFromChildProcesses>
9+
<CodeCoverage>
10+
<ModulePaths>
11+
<Include>
12+
<ModulePath>.*Docfx.*\.dll$</ModulePath>
13+
</Include>
14+
<Exclude>
15+
<!-- Exclude test DLLs -->
16+
<ModulePath>.*Docfx\.Tests\.Common\.dll$</ModulePath>
17+
<ModulePath>.*\.Tests\.dll$</ModulePath>
18+
19+
<!-- Exclude third party DLLs -->
20+
<ModulePath>.*ICSharpCode\.Decompiler\.dll$</ModulePath>
21+
<ModulePath>.*Spectre\.Console\.Cli\.dll$</ModulePath>
22+
<ModulePath>.*Spectre\.Console\.dll$</ModulePath>
23+
<ModulePath>.*DiffEngine\.dll$</ModulePath>
24+
25+
<!-- Following DLLs are included when using `dotnet coverage` commands -->
26+
<ModulePath>.*Argon\.dll$</ModulePath>
27+
<ModulePath>.*EmptyFiles\.dll$</ModulePath>
28+
<ModulePath>.*Verify\.dll$</ModulePath>
29+
<ModulePath>.*Verify\.DiffPlex\.dll$</ModulePath>
30+
<ModulePath>.*Verify\.XunitV3\.dll$</ModulePath>
31+
</Exclude>
32+
</ModulePaths>
33+
<Attributes>
34+
<Exclude>
35+
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
36+
</Exclude>
37+
</Attributes>
38+
<Sources>
39+
<Exclude>
40+
<Source>.*\\[^\\]*\.g\.cs</Source>
41+
</Exclude>
42+
</Sources>
43+
<!-- Disable following settings. Because C++ code is not contained (See: https://github.com/microsoft/codecoverage/blob/main/README.md#get-started)-->
44+
<EnableStaticNativeInstrumentation>False</EnableStaticNativeInstrumentation>
45+
<EnableDynamicNativeInstrumentation>False</EnableDynamicNativeInstrumentation>
46+
</CodeCoverage>
47+
</Configuration>

test/Directory.Build.props

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,69 @@
11
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />
3+
24
<PropertyGroup>
35
<IsPackable>false</IsPackable>
46
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
57
</PropertyGroup>
68

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")]`. -->
711
<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-
-->
1212
<TestTfmsInParallel>false</TestTfmsInParallel>
1313
</PropertyGroup>
1414

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)-->
1616

17-
<ItemGroup>
18-
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
19-
</ItemGroup>
17+
<!-- Following settings are required for .NET 9 SDK and earlier -->
18+
<PropertyGroup Condition="'$(TargetFramework)'=='net9.0' OR '$(TargetFramework)'=='net8.0'">
19+
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
20+
<TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>
21+
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
22+
</PropertyGroup>
23+
24+
<PropertyGroup>
25+
<!-- Use `Microsoft.Testing.Platform` entrypoint -->
26+
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
27+
</PropertyGroup>
28+
29+
<PropertyGroup>
30+
<!-- Show xUnit.net headers and information -->
31+
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --xunit-info</TestingPlatformCommandLineArguments>
2032

33+
<!-- Change TestResults output directory. And enable detailed log outputs -->
34+
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --results-directory "$(MSBuildThisFileDirectory)TestResults"</TestingPlatformCommandLineArguments>
35+
36+
<!-- Ignore exit code 8 (the test session run zero tests) -->
37+
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --ignore-exit-code 8</TestingPlatformCommandLineArguments>
38+
39+
<!-- Enable output for passed tests -->
40+
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --output Detailed</TestingPlatformCommandLineArguments>
41+
</PropertyGroup>
42+
43+
<!-- Settings for CI environment -->
2144
<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>
45+
<!-- Disable progress reports -->
46+
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --no-progress</TestingPlatformCommandLineArguments>
47+
48+
<!-- Enable reporters (trx/html/ctrf ) -->
49+
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-xunit-trx --report-xunit-trx-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).trx</TestingPlatformCommandLineArguments>
50+
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-xunit-html --report-xunit-html-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).html</TestingPlatformCommandLineArguments>
51+
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-ctrf --report-ctrf-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).ctrf</TestingPlatformCommandLineArguments>
2552
</PropertyGroup>
2653

2754
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
55+
56+
<!-- Set [assembly:CaptureConsole] attribute to assembly -->
57+
<AssemblyAttribute Include="Xunit.CaptureConsole" />
58+
59+
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
60+
<None Include="$(MSBuildThisFileDirectory)xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
61+
62+
<!-- Add Docfx.Tests.Common` project reference to test projects -->
2863
<ProjectReference Include="$(MSBuildThisFileDirectory)Docfx.Tests.Common/Docfx.Tests.Common.csproj" />
29-
</ItemGroup>
3064

31-
<ItemGroup>
3265
<PackageReference Include="AwesomeAssertions" />
33-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
34-
<PackageReference Include="xunit.runner.visualstudio" />
35-
<PackageReference Include="xunit" />
66+
<PackageReference Include="xunit.v3.mtp-v2" />
67+
3668
</ItemGroup>
3769
</Project>

test/Directory.Packages.props

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
<ItemGroup>
66
<PackageVersion Include="AwesomeAssertions" Version="9.3.0" />
7-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
8-
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
9-
<PackageVersion Include="Verify.Xunit" Version="31.9.2" />
10-
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
11-
<PackageVersion Include="xunit" Version="2.9.3" />
127
</ItemGroup>
13-
8+
149
<ItemGroup>
15-
<GlobalPackageReference Include="coverlet.collector" Version="6.0.4" />
10+
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
11+
<PackageVersion Include="Verify.XunitV3" Version="31.9.2" />
12+
<PackageVersion Include="xunit.v3" Version="3.2.1" />
13+
<PackageVersion Include="xunit.v3.assert" Version="3.2.1" />
14+
<PackageVersion Include="xunit.v3.extensibility.core" Version="3.2.1" />
15+
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.1" />
1616
</ItemGroup>
17+
1718
</Project>

test/Docfx.Build.Common.Tests/Docfx.Build.Common.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<IsTestProject>true</IsTestProject>
5+
</PropertyGroup>
6+
27
<ItemGroup>
38
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
49
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />

test/Docfx.Build.ManagedReference.Tests/Docfx.Build.ManagedReference.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<IsTestProject>true</IsTestProject>
5+
</PropertyGroup>
6+
27
<ItemGroup>
38
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
49
<ProjectReference Include="..\..\src\Docfx.Build.ManagedReference\Docfx.Build.ManagedReference.csproj" />

test/Docfx.Build.OverwriteDocuments.Tests/Docfx.Build.OverwriteDocuments.Tests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<IsTestProject>true</IsTestProject>
5+
</PropertyGroup>
6+
27
<ItemGroup>
38
<PackageReference Include="Markdig" />
49
</ItemGroup>
10+
511
<ItemGroup>
612
<ProjectReference Include="..\..\src\Docfx.Build.OverwriteDocuments\Docfx.Build.OverwriteDocuments.csproj" />
713
</ItemGroup>

test/Docfx.Build.RestApi.Tests/Docfx.Build.RestApi.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<IsTestProject>true</IsTestProject>
5+
</PropertyGroup>
6+
27
<ItemGroup>
38
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
49
</ItemGroup>

0 commit comments

Comments
 (0)