dotnet-testing-advanced-xunit-upgrade-guide_skill

This skill guides upgrading xUnit 2.x projects to 3.x, enabling migration best practices, async lifecycle updates, and new features for robust tests.
  • C#

19

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill kevintsengtw/dotnet-testing-agent-skills --skill dotnet-testing-advanced-xunit-upgrade-guide

  • SKILL.md12.0 KB

Overview

This skill is a practical, step-by-step guide for upgrading xUnit test projects from 2.9.x to 3.x. It highlights package renames, required project changes, breaking changes to fix, and new xUnit v3 features you can adopt to improve tests. Use it to plan and execute a safe migration with verification and CI checks.

How this skill works

The guide inspects project files, package references, and test code patterns to identify required changes: switch to xunit.v3 packages, change OutputType to Exe, update target frameworks, and find async void tests and old abstractions. It documents code fixes (async Task, IAsyncLifetime adjustments), updated DataAttribute signatures, and new test features like Assert.Skip, Explicit tests, MatrixTheoryData, and AssemblyFixture, plus recommended verification steps.

When to use it

  • When migrating an existing xUnit 2.x test suite to xUnit 3.x
  • When evaluating compatibility impact of updating test dependencies
  • When CI or IDE fails to discover tests after an attempted upgrade
  • When adopting xUnit v3 features like Assert.Skip or Matrix Theory
  • When consolidating async cleanup logic to IAsyncLifetime/DisposeAsync

Best practices

  • Create a dedicated upgrade branch and back up the test project before changes
  • Target supported runtimes (.NET 8+ or .NET Framework 4.7.2+) and convert to SDK-style if needed
  • Search and replace async void test methods to async Task using a regex
  • Move all cleanup to DisposeAsync when implementing IAsyncLifetime to avoid missing Dispose calls
  • Replace SkippableFact/SkippableTheory with Assert.Skip or SkipUnless/SkipWhen attributes
  • Run full build, dotnet test, and CI pipeline validation after changes

Example use cases

  • Update a large test suite: change PackageReference to xunit.v3, set OutputType to Exe, and fix failures
  • Implement AssemblyFixture to provision and tear down an integration database across tests
  • Convert custom DataAttribute implementations to the new async signature and return type
  • Run selective long-running tests by marking them [Fact(Explicit = true)] and gating with Assert.Skip
  • Adopt MatrixTheoryData to generate Cartesian product test cases for combinatorial coverage

FAQ

xUnit 3.x requires .NET Framework 4.7.2+ or .NET 8.0+; older .NET Core/.NET 5–7 are not supported.

Why did my IDisposable cleanup stop running after upgrading?

In xUnit 3.x IAsyncLifetime inherits IAsyncDisposable and only DisposeAsync is called. Move cleanup into DisposeAsync or call synchronous cleanup from DisposeAsync.

How do I find async void tests to fix?

Search with regex like async\s+void.*[(Fact|Theory)] and change methods to return Task.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
dotnet-testing-advanced-xunit-upgrade-guide skill by kevintsengtw/dotnet-testing-agent-skills | VeilStrat