Skip to content

Commit dce2963

Browse files
committed
chore: update xunit version to v3
1 parent 1495da2 commit dce2963

File tree

37 files changed

+374
-104
lines changed

37 files changed

+374
-104
lines changed

.github/workflows/ci.yml

Lines changed: 22 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,17 +41,24 @@ 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+
- run: dotnet test -c Release -f net8.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal" -- --seed ${{ env.seed }}
3552
id: test-net80
3653

37-
- run: dotnet test -c Release -f net9.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal"
54+
- run: dotnet test -c Release -f net9.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal" -- --seed ${{ env.seed }}
3855
if: matrix.os == 'ubuntu-latest'
3956
id: test-net90
4057

4158
- run: npm i -g @percy/cli
4259
if: matrix.os == 'ubuntu-latest'
4360

44-
- run: percy exec -- dotnet test -c Release -f net8.0 --filter Stage=Percy --no-build --collect:"XPlat Code Coverage"
61+
- run: percy exec -- dotnet test -c Release -f net8.0 --no-build --collect:"XPlat Code Coverage" -- --filter-trait "Stage=Percy"
4562
if: matrix.os == 'ubuntu-latest'
4663
env:
4764
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
@@ -70,8 +87,10 @@ jobs:
7087
name: logs-${{ matrix.os }}
7188
path: |
7289
msbuild.binlog
90+
test/**/TestResults/*.log
7391
test/**/TestResults/*.trx
7492
test/**/TestResults/*.html
93+
test/**/TestResults/*.ctrf
7594
7695
- uses: actions/upload-artifact@v4
7796
if: ${{ failure() && matrix.os == 'ubuntu-latest' }}

docfx.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{926A0726-B
1616
ProjectSection(SolutionItems) = preProject
1717
test\Directory.Build.props = test\Directory.Build.props
1818
test\Directory.Packages.props = test\Directory.Packages.props
19+
test\xunit.runner.json = test\xunit.runner.json
1920
EndProjectSection
2021
EndProject
2122
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>

samples/seed/dotnet/assembly/BuildFromAssembly.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.SourceLink.GitHub">
13+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1616
</PackageReference>

test/Directory.Build.props

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,82 @@
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>
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>
2041

42+
<!-- Settings for CI environment -->
2143
<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. -->
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 -->
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'">
28-
<ProjectReference Include="$(MSBuildThisFileDirectory)Docfx.Tests.Common/Docfx.Tests.Common.csproj" />
29-
</ItemGroup>
3062

31-
<!-- Set additional PackagesReferences to suppress warning MSB3277 (Assembly version conflict) -->
32-
<ItemGroup>
33-
<PackageReference Include="System.Collections.Immutable" />
34-
<PackageReference Include="System.Text.Json" />
35-
</ItemGroup>
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 -->
70+
<ProjectReference Include="$(MSBuildThisFileDirectory)Docfx.Tests.Common/Docfx.Tests.Common.csproj" />
3671

37-
<ItemGroup>
3872
<PackageReference Include="FluentAssertions" />
73+
<PackageReference Include="xunit.v3" />
74+
75+
<!-- Following package will be removed when Microsoft.Testing.Platform is supported on major platforms. -->
3976
<PackageReference Include="Microsoft.NET.Test.Sdk" />
40-
<PackageReference Include="xunit.runner.visualstudio" />
41-
<PackageReference Include="xunit" />
77+
<PackageReference Include="xunit.runner.visualstudio">
78+
<PrivateAssets>all</PrivateAssets>
79+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
80+
</PackageReference>
4281
</ItemGroup>
4382
</Project>

test/Directory.Packages.props

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

55
<ItemGroup>
66
<PackageVersion Include="FluentAssertions" Version="[7.1.0]" />
7-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
87
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
9-
<PackageVersion Include="Verify.Xunit" Version="28.9.0" />
10-
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.1" />
11-
<PackageVersion Include="xunit" Version="2.9.3" />
8+
<PackageVersion Include="Verify.XunitV3" Version="28.11.0" />
9+
<PackageVersion Include="xunit.v3" Version="1.1.0" />
10+
<PackageVersion Include="xunit.v3.assert" Version="1.1.0" />
11+
<PackageVersion Include="xunit.v3.extensibility.core" Version="1.1.0" />
1212
</ItemGroup>
13-
13+
14+
<!-- Following package will be removed when Microsoft.Testing.Platform is supported on major platforms. -->
1415
<ItemGroup>
15-
<GlobalPackageReference Include="coverlet.collector" Version="6.0.4" />
16+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
17+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
1618
</ItemGroup>
1719
</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)