Skip to content

Upgrade tests to xUnit v3 - #562

Merged
elinohlsson merged 5 commits into
mainfrom
feature/upgrade-xunit
Oct 9, 2026
Merged

elinohlsson merged 5 commits into
mainfrom
feature/upgrade-xunit

Conversation

@elinohlsson

@elinohlsson elinohlsson commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Upgrade tests to xUnit v3

Replaces the deprecated xunit 2.9.3 package with xunit.v3 4.0.1 and moves test execution to Microsoft.Testing.Platform.

Test projects

  • Reference xunit.v3 instead of xunit, and remove the obsolete dotnet-xunit tool.
  • Keep xunit.runner.visualstudio and include its buildtransitive assets so the adapter targets are imported.
  • Mark test projects as executables. xUnit v3 hosts the tests in the test assembly.
  • Add Microsoft.Testing.Extensions.CodeCoverage to each test project and remove coverlet.collector. Coverage is now collected with dotnet test --coverage.
  • Pass TestContext.Current.CancellationToken to HttpClient and ReadAsStringAsync calls so the xUnit1051 analyzer is satisfied without suppressing it.

Runner and CI

  • Opt dotnet test into Microsoft.Testing.Platform in global.json. The .NET 10 SDK no longer runs these projects through the VSTest dotnet test path.
  • Update the GitHub Actions and Azure Pipelines test steps to dotnet test --solution ... --coverage.
  • Publish TRX results from the Azure Pipelines run with PublishTestResults, since the old DotNetCoreCLI test task injected VSTest arguments that this runner rejects.

Also included

  • Compile TypeScript before static web asset discovery. A Visual Studio rebuild deleted the generated activelogin-main.js before the SDK collected wwwroot, which failed the build. CI did not hit this because it does not rebuild and the generated file is not in source control.

Test plan

  • dotnet test --solution ActiveLogin.Authentication.sln — 319 tests passed
  • Debug rebuild of the solution, including the ASP.NET Core project that failed on static web assets
  • Confirm the GitHub Actions and Azure Pipelines test jobs collect coverage and publish results

Elin Fokine added 3 commits October 9, 2026 10:11
Replace the deprecated xunit package with xunit.v3 and run tests through Microsoft.Testing.Platform. Test projects are executables, coverage uses Microsoft.Testing.Extensions.CodeCoverage, and the GitHub and Azure Pipelines test commands use the new runner.
Use TestContext.Current.CancellationToken for HttpClient and ReadAsStringAsync calls so xUnit1051 is satisfied without suppressing the analyzer.
Run the TypeScript 7 compiler before static web asset discovery so a rebuild does not fail when the generated activelogin-main.js has been deleted.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The cross-platform CI coverage and result-publishing migration remains explicitly unconfirmed.

0 open findings

What changed in this PR

Upgrades all test projects to xUnit v3 with Microsoft.Testing.Platform and updates CI, coverage, cancellation, and static-web-asset handling.

Changes:

  • Migrates test dependencies and execution to xUnit v3/Microsoft.Testing.Platform.
  • Updates CI coverage and Azure TRX publishing.
  • Compiles TypeScript before static web asset discovery.
File Description
test/​Directory.Build.props Makes test projects executable.
test/​ActiveLogin.Authentication.BankId.UAParser.Test/​ActiveLogin.Authentication.BankId.UAParser.Test.csproj Migrates UAParser tests and coverage.
test/​ActiveLogin.Authentication.BankId.Core.Test/​ActiveLogin.Authentication.BankId.Core.Test.csproj Migrates Core tests and coverage.
test/​ActiveLogin.Authentication.BankId.AzureKeyVault.Test/​ActiveLogin.Authentication.BankId.AzureKeyVault.Test.csproj Migrates Azure Key Vault tests.
test/​ActiveLogin.Authentication.BankId.AspNetCore.Test/​BankId_UiSign_Tests.cs Propagates test cancellation tokens.
test/​ActiveLogin.Authentication.BankId.AspNetCore.Test/​BankId_UiPayment_Tests.cs Propagates test cancellation tokens.
test/​ActiveLogin.Authentication.BankId.AspNetCore.Test/​BankId_UiAuth_Tests.cs Propagates test cancellation tokens.
test/​ActiveLogin.Authentication.BankId.AspNetCore.Test/​ActiveLogin.Authentication.BankId.AspNetCore.Test.csproj Migrates ASP.NET Core tests.
test/​ActiveLogin.Authentication.BankId.Api.Test/​BankIdVerifyApiClient_Tests.cs Adds cancellation to content reads.
test/​ActiveLogin.Authentication.BankId.Api.Test/​BankIdAppApiClient_Tests.cs Adds cancellation to content reads.
test/​ActiveLogin.Authentication.BankId.Api.Test/​ActiveLogin.Authentication.BankId.Api.Test.csproj Migrates API tests and removes obsolete tooling.
src/​ActiveLogin.Authentication.BankId.AspNetCore/​ActiveLogin.Authentication.BankId.AspNetCore.csproj Fixes TypeScript/static-asset ordering.
README.md Documents the new test runner.
global.json Selects Microsoft.Testing.Platform.
azure-pipelines.yml Updates coverage and TRX publishing.
.github/​workflows/​test.yml Updates test workflow invocation.
.github/​workflows/​build.yml Updates build workflow test invocation.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Elin Fokine added 2 commits October 9, 2026 11:35
Microsoft Testing Platform's --coverage flag only produces binary
.coverage files, so Azure DevOps had no HTML report to render.

- Output coverage as Cobertura via --coverage-output-format cobertura
- Add PublishCodeCoverageResults@2 step to publish the results

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The migration is consistent across all test projects and the updated runner, coverage, CI, and asset-build configuration align correctly.

0 open findings

🧠 Review effort: Balanced

@elinohlsson
elinohlsson merged commit 2af30d8 into main Oct 9, 2026
17 checks passed
@elinohlsson
elinohlsson deleted the feature/upgrade-xunit branch October 9, 2026 10:39
@elinohlsson elinohlsson added this to the v13.0.0 milestone Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants