getsentry / getsentry/sentry-dotnet

Migrate test projects from xUnit v2 to xUnit v3

Open
#5,579 1 comment 0 reactions 0 assignees View on GitHub
.NET Repository Maintenance Tests
Dominant language
C#
Stars
770
Forks
248
Avg merge
3d 4h
Merged PRs (30d)
49

Description

## 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](https://github.com/VerifyTests/Verify/blob/31.12.5/src/Verify/Naming/Namer.cs) vs [@ 33.0.1](https://github.com/VerifyTests/Verify/blob/33.0.1/src/Verify/Naming/Namer.cs), 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](https://xunit.net/docs/getting-started/v3/native-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 ``.
- **`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.

Contributor guide

Open the contributing guide

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.