Migrate test projects from xUnit v2 to xUnit v3

Open
#5,579 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
38/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp
Domain
testing

Research direction

Start with test/Directory.Build.props and inventory the roughly 24 *.Tests projects, the 54 ITestOutputHelper usages, and the SkippableFact/SkippableTheory usages. First check whether DeviceRunners has an XHarness xUnit v3 package, then audit Sentry.Testing and TestOutputDiagnosticLogger for v2 APIs. Done means the test projects use the v3 packages and executables, and Android/iOS XHarness CI remains supported.

Written by the indexing model from the issue text.

Description

.NET Repository Maintenance State: Needs Discussion Tests

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). #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.

Dominant language
C#
Stars
775
Forks
262
Avg merge
1d 16h
Merged PRs (30d)
118

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-dotnet

All issues in getsentry/sentry-dotnet

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.