Skip to content

Migrate test suite to xUnit v3 and Microsoft Testing Platform - #9871

Merged
glen-84 merged 11 commits into
mainfrom
gai/xunit3
Jun 10, 2026
Merged

glen-84 merged 11 commits into
mainfrom
gai/xunit3

Conversation

@glen-84

@glen-84 glen-84 commented Jun 8, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Migrate the entire test suite to xUnit v3 on the Microsoft Testing Platform: standardize every test area on xunit.v3 and UseMicrosoftTestingPlatformRunner, collapsing the per-area Xunit2/Xunit3.Directory.Build.props build variants into a single set of props.
  • Make the test harness opt-in: each area's auto-imported test/Directory.Build.props now carries only common settings, while the xUnit v3 + MTP-runner harness moves to a sibling Directory.Test.props that the ~126 runnable test projects import explicitly. Non-test fixtures (the Tests.Utilities helpers, StarWars, the docs fixture, the Mocha helpers) no longer inherit the runner and declare only the deps they use, so they build as plain libraries instead of opting out of the harness.
  • Apply the xUnit1051 analyzer fix across every test project: CancellationToken-accepting calls now pass TestContext.Current.CancellationToken (over 7,600 call sites), so the suite stays clean under TreatWarningsAsErrors.
  • Add UseCultureAttribute to the CookieCrumble.Xunit3 snapshot adapter.
  • Move CI coverage to MTP in both ci.yml and coverage.yml: --coverage --coverage-output-format cobertura --report-trx into per-project results directories, replacing the VSTest --collect/--logger trx collector that doesn't run under the MTP runner.
  • Cleanups: remove per-project <IsPackable>false</IsPackable> now inherited from the shared props; drop the unused xunit v2 metapackage and a temporary xunit.analyzers pin from Directory.Packages.props; update global.json.

Test fixes

Running on xUnit v3 / MTP surfaced a set of latent test problems that VSTest/v2 had masked. None are product-behaviour regressions; each is a test-side fix, grouped by root cause:

  • MTP fails a run when zero tests execute (exit 8). Deleted the empty, abandoned Fusion.EventSources.Tests project, and renamed the StarWars schema-fixture project off the .Tests suffix so the name-based CI matrix stops invoking it as a test.
  • v3 invokes IAsyncDisposable teardown that v2 skipped. CommandTestBase (Nitro CLI) moved to IAsyncLifetime so its Strict-mock VerifyAll actually runs; the over-specified mock setups it then flagged were corrected via Run CommandTestBase teardown via IAsyncLifetime on xUnit v2 #9872, and the lifecycle is reconciled to v3's ValueTask signatures here.
  • Test-isolation collisions exposed by v3's test ordering. The Raven projections SchemaCache now keys on objectType (sibling tests no longer share a resolver-less schema), and the SqlServer filter tests use a unique SQLite file per schema build (no cross-test database contamination). A Raven projection snapshot that had captured the pre-fix error was refreshed to the correct result.
  • Timing/scheduling flakes exposed under MTP parallelism, replaced with deterministic waits.
    • ActivityTestHelper (Diagnostics + Fusion) waits for span-export quiescence instead of racing the read.
    • Postgres reconnect tests await a TaskCompletionSource instead of a blocking SpinWait.SpinUntil, which deadlocked awaited continuations on the v3 synchronization context.
    • The @defer/@stream snapshot tests (StreamTests, DeferTests, DeferReferenceTests) capture an aggregated snapshot that is independent of incremental-vs-bundled delivery (a new MatchAggregatedSnapshot / MatchAggregatedMarkdownSnapshot helper). The one test that asserts the raw incremental structure (field dedup) is left raw, since its delivery is deterministic.
    • SubscriptionEventTimeoutTests await the subscription teardown (MoveNextAsync completing) directly rather than a fixed Task.WhenAny(..., Task.Delay(...)) race window that was too tight under load.
    • CancellationTests cancels from within the running resolver rather than relying on a 150 ms wall-clock token.
    • EvictSchemaTests polls the endpoint until it serves the re-created schema instead of using fixed delays.
  • Misc. Broadened the AspNetCore CLI OutputHelper usage-parsing regex ([\w]+ → \S+).

Test plan

  • Built every test project on net10.0 and confirmed 0 xUnit1051 diagnostics across all test projects, and that src/All.slnx builds clean after the opt-in restructure.
  • Confirmed the harness reaches all ~126 runnable test projects (they build as Exe test hosts and run under MTP) while the 6 non-test fixtures build as libraries; ran Caching, Types.Tests, Language, and CookieCrumble.Tests to confirm the runner chain still works.
  • Verified MTP coverage/TRX end-to-end: the CI flags emit *.cobertura.xml + *.trx matching the artifact upload globs, with real coverage data and the test assembly excluded.
  • Ran each affected test suite locally (real RavenDB / Postgres / SQLite containers where applicable) and confirmed the fixes pass and are stable across repeated runs, including the full Execution.Tests assembly across repeated runs to shake out the defer/stream delivery-timing flakes.

Copilot AI review requested due to automatic review settings June 8, 2026 08:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants