Skip to content

Commit

Permalink
chore: update xunit version to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
filzrev committed Dec 27, 2024
1 parent 0cceb23 commit ff545e2
Show file tree
Hide file tree
Showing 39 changed files with 392 additions and 95 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ on:
push:
branches: [ main, feature/*, hotfix/* ]
workflow_dispatch:
inputs:
seed:
description: 'Enter an integer value between 0 and 2147483647.'
type: number
required: true
default: 0

env:
seed: ${{ inputs.seed || github.run_number }}
NO_COLOR: true

jobs:
test:
Expand All @@ -31,25 +41,32 @@ jobs:
shell: bash
working-directory: templates

- run: dotnet test -c Release -f net8.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal"
- name: Install Chromium headless shell
shell: pwsh
working-directory: src/docfx/bin/Release/net8.0
run: |
$env:PLAYWRIGHT_NODEJS_PATH = (Get-Command node).Path
./playwright.ps1 install chromium --only-shell
- run: dotnet test -c Release -f net8.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal" -- --seed ${{ env.seed }}
id: test-net80

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

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

- run: percy exec -- dotnet test -c Release -f net8.0 --filter Stage=Percy --no-build --collect:"XPlat Code Coverage"
- run: percy exec -- dotnet test -c Release -f net8.0 --no-build --collect:"XPlat Code Coverage" -- --filter-trait "Stage=Percy"
if: matrix.os == 'ubuntu-latest'
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}

- uses: codecov/codecov-action@v5
if: matrix.os == 'ubuntu-latest'
with:
fail_ci_if_error: true
fail_ci_if_error: false

- run: echo "DOTNET_DbgEnableMiniDump=1" >> $GITHUB_ENV
if: matrix.os == 'ubuntu-latest'
Expand All @@ -69,8 +86,10 @@ jobs:
name: logs-${{ matrix.os }}
path: |
msbuild.binlog
test/**/TestResults/*.log
test/**/TestResults/*.trx
test/**/TestResults/*.html
test/**/TestResults/*.ctrf
- uses: actions/upload-artifact@v4
if: ${{ failure() && matrix.os == 'ubuntu-latest' }}
Expand Down
1 change: 1 addition & 0 deletions docfx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{926A0726-B
ProjectSection(SolutionItems) = preProject
test\Directory.Build.props = test\Directory.Build.props
test\Directory.Packages.props = test\Directory.Packages.props
test\xunit.runner.json = test\xunit.runner.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "docfx", "src\docfx\docfx.csproj", "{EF53214F-BA98-4026-BEED-CF771865C312}"
Expand Down
2 changes: 2 additions & 0 deletions samples/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<Project>
</Project>
2 changes: 1 addition & 1 deletion samples/seed/dotnet/assembly/BuildFromAssembly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
67 changes: 57 additions & 10 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,33 +1,80 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<IsPackable>false</IsPackable>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>

<!-- .NET 9 or later run tests per TargetFramework in parallel by default.
It is necessary to disable this feature because there are tests that need to be executed sequentially that are marked with `[Collection("docfx STA")]`. -->
<PropertyGroup>
<!--
.NET 9 preview 2 or later run tests in parallel by default.
It is necessary to disable this feature because there are tests that need to be executed sequentially that are marked with `[Collection("docfx STA")]`.
-->
<TestTfmsInParallel>false</TestTfmsInParallel>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />
<!-- Configure `Microsoft.Testing.Platform` mode behaviors (https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-integration-dotnet-test)-->
<PropertyGroup>
<!-- Enable `Microsoft.Testing.Platform` mode for `dotnet test` -->
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>

<ItemGroup>
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<!-- Show failure per test -->
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>

<!-- Show complete platform output -->
<TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>

<!-- Use `Microsoft.Testing.Platform` entrypoint. -->
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>

<!-- Show xUnit.net headers and information -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --xunit-info</TestingPlatformCommandLineArguments>

<!-- Change TestResults output directory. And enable detailed log outputs -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --results-directory "$(MSBuildThisFileDirectory)TestResults"</TestingPlatformCommandLineArguments>

<!-- Ignore exit code 8 (the test session run zero tests) -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --ignore-exit-code 8</TestingPlatformCommandLineArguments>

<!-- Enable output for passed tests -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --output Detailed</TestingPlatformCommandLineArguments>
</PropertyGroup>

<!-- Settings for CI environment -->
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true' AND '$(PERCY_TOKEN)' == ''">
<!-- Disable progress reports -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --no-progress</TestingPlatformCommandLineArguments>

<!-- Enable reporters (trx/html/ctrf ) -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-xunit-trx --report-xunit-trx-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).trx</TestingPlatformCommandLineArguments>
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-xunit-html --report-xunit-html-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).html</TestingPlatformCommandLineArguments>
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --report-ctrf --report-ctrf-filename TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).ctrf</TestingPlatformCommandLineArguments>
</PropertyGroup>

<!-- Settings for VSTest mode. These settings will be removed in future. -->
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true' AND '$(PERCY_TOKEN)' == ''">
<!-- See: https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-vs-vstest#communication-protocol-preview -->
<VSTestResultsDirectory>$(MSBuildThisFileDirectory)TestResults</VSTestResultsDirectory>
<VSTestLogger>$(VSTestLogger);trx%3BLogFileName=TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).trx</VSTestLogger>
<VSTestLogger>$(VSTestLogger);html%3BLogFileName=TestResults-$(MSBuildProjectName)-$(TargetFramework)-$(RUNNER_OS).html</VSTestLogger>
</PropertyGroup>

<!-- Add [assembly:CaptureConsole] attribute to assemblies -->
<ItemGroup>
<AssemblyAttribute Include="Xunit.CaptureConsole" />
</ItemGroup>

<ItemGroup>
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
<None Include="$(MSBuildThisFileDirectory)xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.v3" />
</ItemGroup>
</Project>
7 changes: 3 additions & 4 deletions test/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)../'))" />

<ItemGroup>
<PackageVersion Include="FluentAssertions" Version="7.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
<PackageVersion Include="Verify.Xunit" Version="28.4.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="Verify.XunitV3" Version="28.6.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />
<PackageVersion Include="xunit.v3" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions test/Docfx.Build.Common.Tests/Docfx.Build.Common.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.ManagedReference\Docfx.Build.ManagedReference.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Markdig" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.OverwriteDocuments\Docfx.Build.OverwriteDocuments.csproj" />
<ProjectReference Include="..\Docfx.Tests.Common\Docfx.Tests.Common.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<None Include="TestData\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.OperationLevelRestApi\Docfx.Build.OperationLevelRestApi.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build.TagLevelRestApi\Docfx.Build.TagLevelRestApi.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Docfx.Build.Common\Docfx.Build.Common.csproj" />
<ProjectReference Include="..\..\src\Docfx.Build\Docfx.Build.csproj" />
Expand Down
4 changes: 4 additions & 0 deletions test/Docfx.Build.Tests/Docfx.Build.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<Compile Remove="TestData\snippets\dataflowdegreeofparallelism.cs" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Docfx.Build.Tests/ExtractSearchIndexFromHtmlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ This is article title
manifest.Files.Add(manifestItem);

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

var expectedIndexJSON = @"{
""index.html"": {
Expand Down
10 changes: 1 addition & 9 deletions test/Docfx.Build.Tests/PostProcessors/SitemapGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@
using Docfx.Plugins;
using Docfx.Tests.Common;
using Xunit;
using Xunit.Abstractions;
using DocumentType = Docfx.DataContracts.Common.Constants.DocumentType;

namespace Docfx.Build.Engine.Tests;

[Collection("docfx STA")]
public class SitemapGeneratorTests : TestBase
{
private readonly ITestOutputHelper _output;

public SitemapGeneratorTests(ITestOutputHelper output)
{
_output = output;
}

public override void Dispose()
{
base.Dispose();
Expand Down Expand Up @@ -58,7 +50,7 @@ public void TestSitemapGenerator()
var sitemapPath = Path.Combine(outputFolder, "sitemap.xml");

// Act
manifest = sitemapGenerator.Process(manifest, outputFolder);
manifest = sitemapGenerator.Process(manifest, outputFolder, TestContext.Current.CancellationToken);

// Assert
Assert.Equal("https://example.com/", manifest.Sitemap.BaseUrl);
Expand Down
2 changes: 1 addition & 1 deletion test/Docfx.Build.Tests/RemoveDebugInfoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void TestBasicFeature()
new HtmlPostProcessor
{
Handlers = { new RemoveDebugInfo() }
}.Process(manifest, _outputFolder);
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);

var actual = File.ReadAllText(Path.Combine(_outputFolder, "a.html"));
Assert.Equal("<p id='b1'>section<a href='http://bing.com#top'>Microsoft Bing</a></p>", actual);
Expand Down
6 changes: 3 additions & 3 deletions test/Docfx.Build.Tests/ValidateBookmarkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void TestBasicFeature()
new HtmlPostProcessor
{
Handlers = { new ValidateBookmark() }
}.Process(manifest, _outputFolder);
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);
}
finally
{
Expand Down Expand Up @@ -107,7 +107,7 @@ public void TestNoCheck()
new HtmlPostProcessor
{
Handlers = { new ValidateBookmark() }
}.Process(manifest, _outputFolder);
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);
}
finally
{
Expand Down Expand Up @@ -150,7 +150,7 @@ public void TestLinkThatContainsNonAsciiChars()
new HtmlPostProcessor
{
Handlers = { new ValidateBookmark() }
}.Process(manifest, _outputFolder);
}.Process(manifest, _outputFolder, TestContext.Current.CancellationToken);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion test/Docfx.Build.Tests/XRefArchiveBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task TestDownload()
// sorted: true
// references: []
// ```
Assert.True(await builder.DownloadAsync(new Uri("http://dotnet.github.io/docfx/xrefmap.yml"), ZipFile));
Assert.True(await builder.DownloadAsync(new Uri("http://dotnet.github.io/docfx/xrefmap.yml"), ZipFile, TestContext.Current.CancellationToken));

using (var xar = XRefArchive.Open(ZipFile, XRefArchiveMode.Read))
{
Expand Down
Loading

0 comments on commit ff545e2

Please sign in to comment.