Skip to content

Commit e5fea21

Browse files
committed
chore: update xunit version to v3
1 parent 6716bb9 commit e5fea21

File tree

37 files changed

+435
-83
lines changed

37 files changed

+435
-83
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ on:
55
push:
66
branches: [ main, feature/*, hotfix/* ]
77
workflow_dispatch:
8+
inputs:
9+
seed:
10+
description: 'Enter an integer value between 0 and 2147483647.'
11+
type: number
12+
required: true
13+
default: 0
14+
15+
env:
16+
seed: ${{ inputs.seed || github.run_number }}
17+
NO_COLOR: true
818

919
jobs:
1020
test:
@@ -31,26 +41,43 @@ jobs:
3141
shell: bash
3242
working-directory: templates
3343

34-
- run: dotnet test -c Release -f net8.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal"
44+
- name: Install Chromium headless shell
45+
shell: pwsh
46+
working-directory: src/docfx/bin/Release/net8.0
47+
run: |
48+
$env:PLAYWRIGHT_NODEJS_PATH = (Get-Command node).Path
49+
./playwright.ps1 install chromium --only-shell
50+
51+
- name: Install `dotnet-coverage` as .NET Global Tool
52+
run: dotnet tool install -g dotnet-coverage
53+
54+
- name: Start dotnet-coverage with background server mode
55+
run: dotnet coverage collect --session-id docfx_coverage --settings test/CodeCoverage.runsettings --server-mode --background
56+
57+
- run: dotnet coverage connect docfx_coverage "dotnet test -c Release -f net8.0 --no-build -- --seed ${{ env.seed }}"
3558
id: test-net80
3659

37-
- run: dotnet test -c Release -f net9.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal"
60+
- run: dotnet coverage connect docfx_coverage "dotnet test -c Release -f net9.0 --no-build -- --seed ${{ env.seed }}"
3861
if: matrix.os == 'ubuntu-latest'
3962
id: test-net90
4063

4164
- run: npm i -g @percy/cli
4265
if: matrix.os == 'ubuntu-latest'
4366

44-
- run: percy exec -- dotnet test -c Release -f net8.0 --filter Stage=Percy --no-build --collect:"XPlat Code Coverage"
67+
- run: dotnet coverage connect docfx_coverage "percy exec -- dotnet test -c Release -f net8.0 --no-build -- --filter-trait "Stage=Percy" --seed ${{ env.seed }}"
4568
if: matrix.os == 'ubuntu-latest'
4669
env:
4770
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
4871

72+
- name: Shutdown dotnet-coverage server.
73+
run: dotnet coverage shutdown docfx_coverage --timeout 60000
74+
4975
- uses: codecov/codecov-action@v5
5076
if: matrix.os == 'ubuntu-latest'
5177
with:
5278
fail_ci_if_error: false
5379
token: ${{ secrets.CODECOV_TOKEN }}
80+
directory: test/TestResults/code-coverages
5481

5582
- run: echo "DOTNET_DbgEnableMiniDump=1" >> $GITHUB_ENV
5683
if: matrix.os == 'ubuntu-latest'
@@ -70,8 +97,10 @@ jobs:
7097
name: logs-${{ matrix.os }}
7198
path: |
7299
msbuild.binlog
100+
test/**/TestResults/*.log
73101
test/**/TestResults/*.trx
74102
test/**/TestResults/*.html
103+
test/**/TestResults/*.ctrf
75104
76105
- uses: actions/upload-artifact@v4
77106
if: ${{ failure() && matrix.os == 'ubuntu-latest' }}

docfx.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ EndProject
1515
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{926A0726-B806-4215-82EF-AF8E22D0FACF}"
1616
ProjectSection(SolutionItems) = preProject
1717
test\Directory.Build.props = test\Directory.Build.props
18+
test\CodeCoverage.runsettings = test\CodeCoverage.runsettings
1819
test\Directory.Packages.props = test\Directory.Packages.props
20+
test\xunit.runner.json = test\xunit.runner.json
1921
EndProjectSection
2022
EndProject
2123
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "docfx", "src\docfx\docfx.csproj", "{EF53214F-BA98-4026-BEED-CF771865C312}"

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 & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,76 @@
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)-->
16+
<PropertyGroup>
17+
<!-- Enable `Microsoft.Testing.Platform` mode for `dotnet test` -->
18+
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
1619

17-
<ItemGroup>
18-
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
19-
</ItemGroup>
20+
<!-- Show failure per test -->
21+
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
2022

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. -->
2154
<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 -->
2256
<VSTestResultsDirectory>$(MSBuildThisFileDirectory)TestResults</VSTestResultsDirectory>
2357
<VSTestLogger>$(VSTestLogger);trx%3BLogFileName=TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).trx</VSTestLogger>
2458
<VSTestLogger>$(VSTestLogger);html%3BLogFileName=TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).html</VSTestLogger>
2559
</PropertyGroup>
2660

2761
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
62+
63+
<!-- Set [assembly:CaptureConsole] attribute to assembly -->
64+
<AssemblyAttribute Include="Xunit.CaptureConsole" />
65+
66+
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
67+
<None Include="$(MSBuildThisFileDirectory)xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
68+
69+
<!-- Add Docfx.Tests.Common` project reference to test projects -->
2870
<ProjectReference Include="$(MSBuildThisFileDirectory)Docfx.Tests.Common/Docfx.Tests.Common.csproj" />
29-
</ItemGroup>
3071

31-
<ItemGroup>
3272
<PackageReference Include="AwesomeAssertions" />
33-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
34-
<PackageReference Include="xunit.runner.visualstudio" />
35-
<PackageReference Include="xunit" />
73+
<PackageReference Include="xunit.v3" />
74+
3675
</ItemGroup>
3776
</Project>

test/Directory.Packages.props

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />
44

55
<ItemGroup>
6-
<PackageVersion Include="AwesomeAssertions" Version="9.0.0" />
7-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
6+
<PackageVersion Include="AwesomeAssertions" Version="9.2.0" />
87
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
9-
<PackageVersion Include="Verify.Xunit" Version="30.19.1" />
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="30.19.2" />
9+
<PackageVersion Include="xunit.v3" Version="3.1.0" />
10+
<PackageVersion Include="xunit.v3.assert" Version="3.1.0" />
11+
<PackageVersion Include="xunit.v3.extensibility.core" Version="3.1.0" />
1612
</ItemGroup>
13+
1714
</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)