Skip to content

Commit 8155f72

Browse files
committed
chore: update xunit version to v3
1 parent 8b43a7a commit 8155f72

File tree

43 files changed

+445
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+445
-106
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' }}

Directory.Build.props

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040
<PackageLicenseExpression>MIT</PackageLicenseExpression>
4141
</PropertyGroup>
4242

43-
<ItemGroup>
44-
<None Include="$(MSBuildThisFileDirectory)\README.md" Pack="true" PackagePath="\" />
45-
</ItemGroup>
46-
4743
<!-- Remove Node.js runtime dependencies that used by playwright -->
4844
<Target Name="RemoveNodeJsRuntimes" AfterTargets="CopyPlaywrightFilesToOutput">
4945
<ItemGroup>

Directory.Build.targets

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
3+
<ItemGroup Condition="'$(IsPackable)' == 'true'">
4+
<None Include="$(MSBuildThisFileDirectory)\README.md" Pack="true" PackagePath="\" />
5+
</ItemGroup>
6+
7+
</Project>

docfx.slnx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Folder Name="/Solution Items/">
33
<File Path=".editorconfig" />
44
<File Path="Directory.Build.props" />
5+
<File Path="Directory.Build.targets" />
56
<File Path="Directory.Packages.props" />
67
</Folder>
78
<Folder Name="/src/">
@@ -38,6 +39,7 @@
3839
</Folder>
3940
<Folder Name="/test/">
4041
<File Path="test/Directory.Build.props" />
42+
<File Path="test/Directory.Build.targets" />
4143
<File Path="test/Directory.Packages.props" />
4244
<Project Path="test/Docfx.Build.Common.Tests/Docfx.Build.Common.Tests.csproj" />
4345
<Project Path="test/Docfx.Build.Tests/Docfx.Build.Tests.csproj" />

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: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,72 @@
11
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />
3+
24
<PropertyGroup>
35
<IsPackable>false</IsPackable>
46
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
7+
<IsTestingPlatformApplication>true</IsTestingPlatformApplication>
8+
<IsTestProject>true</IsTestProject>
59
</PropertyGroup>
610

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")]`. -->
713
<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-
-->
1214
<TestTfmsInParallel>false</TestTfmsInParallel>
1315
</PropertyGroup>
1416

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

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>
2034

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 -->
2146
<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>
2554
</PropertyGroup>
2655

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 -->
2865
<ProjectReference Include="$(MSBuildThisFileDirectory)Docfx.Tests.Common/Docfx.Tests.Common.csproj" />
29-
</ItemGroup>
3066

31-
<ItemGroup>
67+
<!-- Add common test package references -->
3268
<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" />
3670
</ItemGroup>
71+
3772
</Project>

test/Directory.Build.targets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />
3+
</Project>

test/Directory.Packages.props

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

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

0 commit comments

Comments
 (0)