Skip to content

Migrate test projects from xUnit v2 to xUnit v3 #5579

Description

@jamescrosswell

Problem

Our tests use xUnit v2 (xunit 2.9.3). The v2 line is effectively frozen, and the ecosystem around it is moving to v3:

  • Verify — v33 dropped Verify.Xunit (v2) in favour of Verify.XunitV3, so we're stuck on Verify.Xunit 31.x. One visible symptom: Verify 31.x has no net11.0 build, so net11 tests load its net10 build and received snapshot files get named *.DotNet11_0.DotNet10_0.received.txt (Namer.cs @ 31.12.5 vs @ 33.0.1, which adds NET11_0). Cosmetic today, but we'll keep missing fixes like this.
  • Native AOT — xUnit v3 supports Native AOT as of 4.0, via xunit.v3.aot and source generators (docs). Can we run unit tests in AOT? #3930 assumed xUnit couldn't do AOT and pointed at TUnit; v3 removes the test framework itself as the blocker, though NSubstitute and Verify serialisation still are.

Scope

  • Packages — xunit → xunit.v3, Verify.Xunit → Verify.XunitV3, xunit.runner.visualstudio to a v3-compatible version (test/Directory.Build.props).
  • Test projects become executables — about 24 *.Tests projects.
  • Xunit.Abstractions is gone — ITestOutputHelper moves namespace. It's used in about 54 files, including the global <Using Include="Xunit.Abstractions" />.
  • Xunit.SkippableFact doesn't support v3 — about 36 files use [SkippableFact]/[SkippableTheory]/Skip.If. v3 has dynamic skipping built in (Assert.Skip, Assert.SkipWhen/SkipUnless).
  • Device tests — Sentry.Maui.Device.TestApp uses DeviceRunners.XHarness.Xunit (0.1.0-preview.5). DeviceRunners has Xunit3 packages for its visual runner (DeviceRunners.VisualRunners.Xunit3), but there's no XHarness Xunit3 package yet. This probably gates the whole migration, since the Android/iOS CI jobs run through XHarness. Check before starting.
  • Other extensions — audit anything else built against v2 APIs (custom attributes/discoverers in Sentry.Testing, TestOutputDiagnosticLogger, etc.).

Out of scope

Actually running tests under Native AOT; that stays with #3930. Migrating to v3 is a prerequisite, not the whole job: NSubstitute (Castle proxies) and Verify serialisation (VerifyTests/Verify#1526) remain AOT blockers.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions