Skip to content

Commit ff545e2

Browse files
committed
chore: update xunit version to v3
1 parent 0cceb23 commit ff545e2

File tree

39 files changed

+392
-95
lines changed

39 files changed

+392
-95
lines changed

.github/workflows/ci.yml

+23-4
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,25 +41,32 @@ 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 }}
4865

4966
- uses: codecov/codecov-action@v5
5067
if: matrix.os == 'ubuntu-latest'
5168
with:
52-
fail_ci_if_error: true
69+
fail_ci_if_error: false
5370

5471
- run: echo "DOTNET_DbgEnableMiniDump=1" >> $GITHUB_ENV
5572
if: matrix.os == 'ubuntu-latest'
@@ -69,8 +86,10 @@ jobs:
6986
name: logs-${{ matrix.os }}
7087
path: |
7188
msbuild.binlog
89+
test/**/TestResults/*.log
7290
test/**/TestResults/*.trx
7391
test/**/TestResults/*.html
92+
test/**/TestResults/*.ctrf
7493
7594
- uses: actions/upload-artifact@v4
7695
if: ${{ failure() && matrix.os == 'ubuntu-latest' }}

docfx.sln

+1
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

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<Project>
2+
</Project>

samples/seed/dotnet/assembly/BuildFromAssembly.csproj

+1-1
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

+57-10
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,80 @@
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

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+
2771
<ItemGroup>
2872
<PackageReference Include="FluentAssertions" />
2973
<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" />
3279
</ItemGroup>
3380
</Project>

test/Directory.Packages.props

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
21
<Project>
32
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />
43

54
<ItemGroup>
65
<PackageVersion Include="FluentAssertions" Version="7.0.0" />
76
<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.4.0" />
10-
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
11-
<PackageVersion Include="xunit" Version="2.9.2" />
8+
<PackageVersion Include="Verify.XunitV3" Version="28.6.0" />
9+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />
10+
<PackageVersion Include="xunit.v3" Version="1.0.0" />
1211
</ItemGroup>
1312

1413
<ItemGroup>

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

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
</PropertyGroup>
5+
26
<ItemGroup>
37
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
48
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />

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

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
</PropertyGroup>
5+
26
<ItemGroup>
37
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
48
<ProjectReference Include="..\..\src\Docfx.Build.ManagedReference\Docfx.Build.ManagedReference.csproj" />

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

+5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
</PropertyGroup>
5+
26
<ItemGroup>
37
<PackageReference Include="Markdig" />
48
</ItemGroup>
9+
510
<ItemGroup>
611
<ProjectReference Include="..\..\src\Docfx.Build.OverwriteDocuments\Docfx.Build.OverwriteDocuments.csproj" />
712
<ProjectReference Include="..\Docfx.Tests.Common\Docfx.Tests.Common.csproj" />

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

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
</PropertyGroup>
5+
26
<ItemGroup>
37
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
48
</ItemGroup>

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

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
</PropertyGroup>
5+
26
<ItemGroup>
37
<ProjectReference Include="..\..\src\Docfx.Build.OperationLevelRestApi\Docfx.Build.OperationLevelRestApi.csproj" />
48
<ProjectReference Include="..\..\src\Docfx.Build.TagLevelRestApi\Docfx.Build.TagLevelRestApi.csproj" />

test/Docfx.Build.SchemaDriven.Tests/Docfx.Build.SchemaDriven.Tests.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
</PropertyGroup>
5+
26
<ItemGroup>
37
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
48
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />

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

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
</PropertyGroup>
5+
26
<ItemGroup>
37
<Compile Remove="TestData\snippets\dataflowdegreeofparallelism.cs" />
48
</ItemGroup>

test/Docfx.Build.Tests/ExtractSearchIndexFromHtmlTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ This is article title
219219
manifest.Files.Add(manifestItem);
220220

221221
// process the fake manifest, using tempTestFolder as the output folder
222-
_extractor.Process(manifest, tempTestFolder);
222+
_extractor.Process(manifest, tempTestFolder, TestContext.Current.CancellationToken);
223223

224224
var expectedIndexJSON = @"{
225225
""index.html"": {

test/Docfx.Build.Tests/PostProcessors/SitemapGeneratorTests.cs

+1-9
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,13 @@
55
using Docfx.Plugins;
66
using Docfx.Tests.Common;
77
using Xunit;
8-
using Xunit.Abstractions;
98
using DocumentType = Docfx.DataContracts.Common.Constants.DocumentType;
109

1110
namespace Docfx.Build.Engine.Tests;
1211

1312
[Collection("docfx STA")]
1413
public class SitemapGeneratorTests : TestBase
1514
{
16-
private readonly ITestOutputHelper _output;
17-
18-
public SitemapGeneratorTests(ITestOutputHelper output)
19-
{
20-
_output = output;
21-
}
22-
2315
public override void Dispose()
2416
{
2517
base.Dispose();
@@ -58,7 +50,7 @@ public void TestSitemapGenerator()
5850
var sitemapPath = Path.Combine(outputFolder, "sitemap.xml");
5951

6052
// Act
61-
manifest = sitemapGenerator.Process(manifest, outputFolder);
53+
manifest = sitemapGenerator.Process(manifest, outputFolder, TestContext.Current.CancellationToken);
6254

6355
// Assert
6456
Assert.Equal("https://example.com/", manifest.Sitemap.BaseUrl);

test/Docfx.Build.Tests/RemoveDebugInfoTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void TestBasicFeature()
4343
new HtmlPostProcessor
4444
{
4545
Handlers = { new RemoveDebugInfo() }
46-
}.Process(manifest, _outputFolder);
46+
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);
4747

4848
var actual = File.ReadAllText(Path.Combine(_outputFolder, "a.html"));
4949
Assert.Equal("<p id='b1'>section<a href='http://bing.com#top'>Microsoft Bing</a></p>", actual);

test/Docfx.Build.Tests/ValidateBookmarkTest.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void TestBasicFeature()
6363
new HtmlPostProcessor
6464
{
6565
Handlers = { new ValidateBookmark() }
66-
}.Process(manifest, _outputFolder);
66+
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);
6767
}
6868
finally
6969
{
@@ -107,7 +107,7 @@ public void TestNoCheck()
107107
new HtmlPostProcessor
108108
{
109109
Handlers = { new ValidateBookmark() }
110-
}.Process(manifest, _outputFolder);
110+
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);
111111
}
112112
finally
113113
{
@@ -150,7 +150,7 @@ public void TestLinkThatContainsNonAsciiChars()
150150
new HtmlPostProcessor
151151
{
152152
Handlers = { new ValidateBookmark() }
153-
}.Process(manifest, _outputFolder);
153+
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);
154154
}
155155
finally
156156
{

test/Docfx.Build.Tests/XRefArchiveBuilderTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public async Task TestDownload()
2020
// sorted: true
2121
// references: []
2222
// ```
23-
Assert.True(await builder.DownloadAsync(new Uri("http://dotnet.github.io/docfx/xrefmap.yml"), ZipFile));
23+
Assert.True(await builder.DownloadAsync(new Uri("http://dotnet.github.io/docfx/xrefmap.yml"), ZipFile, TestContext.Current.CancellationToken));
2424

2525
using (var xar = XRefArchive.Open(ZipFile, XRefArchiveMode.Read))
2626
{

0 commit comments

Comments
 (0)