Skip to content

Update to xunit.v3 package version 4.0.0 when stable #129

@mattleibow

Description

@mattleibow

Context

The xunit.v3 packages are moving from 3.2.2 to 4.0.0 (still the "xUnit v3" generation, just a SemVer major bump due to breaking changes). The headline feature is Native AOT support. Pre-releases are available on the xunit CI feed (4.0.0-pre.117+).

CI feed: https://f.feedz.io/xunit/xunit/nuget/index.json

Breaking Changes That Affect DeviceRunners

1. FixtureMappingManager parameter added to runner Run() methods

XunitTestCaseRunner.Run() and XunitTestRunner.Run() now require a FixtureMappingManager parameter for fixture lifecycle management.

Affected files:

  • src/DeviceRunners.UITesting.Xunit3/UITestCase.csISelfExecutingXunitTestCase.Run() calls UIXunitTestCaseRunner.Instance.Run()
  • src/DeviceRunners.UITesting.Xunit3/UITheoryTestCase.cs — same pattern
  • src/DeviceRunners.UITesting.Xunit3/UIXunitTestCaseRunner.csRunTest() calls UIXunitTestRunner.Instance.Run()

Fix: Create a new FixtureMappingManager("Method") and pass it as the last argument.

2. TheoryDiscoverer.CreateTestCasesForDataRow is no longer virtual

Cannot override it anymore.

Affected files:

  • src/DeviceRunners.UITesting.Xunit3/UITheoryDiscoverer.cs

Fix: Use new instead of override. Need to verify this still gets called correctly (may need to investigate how the base class invokes it in AOT mode).

3. XunitTestAssembly constructor marked obsolete

The old constructor XunitTestAssembly(Assembly, string?, Version?, string?) is obsolete. A new overload with additional parameters is available.

Affected files:

  • src/DeviceRunners.VisualRunners.Xunit3/InMemoryXunit3TestAssembly.cs

Fix: Suppress warning or migrate to new constructor. Note: The assemblyPath parameter was added to XunitTestAssembly (xunit/xunit#3577), which may allow removing InMemoryXunit3TestAssembly entirely if we can pass the logical path directly.

4. ExtensibilityPointFactory.GetTestFramework(Assembly) is obsolete

Replaced by RegisteredEngineConfig.GetTestFramework.

Affected files:

  • src/DeviceRunners.VisualRunners.Xunit3/InMemoryXunit3TestFramework.cs

Fix: Use RegisteredEngineConfig.GetTestFramework instead.

5. Xunit.Runners namespace removed

Replaced by Xunit.SimpleRunner. Likely does not affect us but worth checking.

Potential Simplification: Remove InMemory Workaround

With xunit/xunit#3577 fixed in 4.0.0, XunitTestAssembly now accepts an assemblyPath constructor parameter. This means InMemoryXunit3TestAssembly and InMemoryXunit3TestFramework may be entirely removable — we could pass the logical path directly to the standard XunitTestAssembly constructor.

Other Notable Changes in 4.0.0

  • Native AOT support — test projects can be AOT-compiled
  • Dropped Mono support — no longer officially supported
  • Dropped Microsoft Testing Platform v1 — only v2 supported
  • Test class & method orderers (new)
  • Generic attribute support (.NET 8+): TestFrameworkAttribute<T>, etc.
  • RemoveAsyncSuffix display option
  • Numeric theory row indexing for sorting
  • ITestMetadata.TestLabel
  • Native console runner as .NET Tool (dotnet xunit-console)
  • StartTime/FinishTime on pipeline events
  • FixtureMappingManager.InitializeAsync() without createInstances removed

Action Items

  • Update Directory.Packages.props xunit.v3 versions to 4.0.0 (when stable)
  • Add FixtureMappingManager parameter to all Run() call sites
  • Change override to new on UITheoryDiscoverer.CreateTestCasesForDataRow
  • Migrate InMemoryXunit3TestFramework.CreateForAssembly to RegisteredEngineConfig.GetTestFramework
  • Evaluate removing InMemoryXunit3TestAssembly/InMemoryXunit3TestFramework entirely (use new assemblyPath constructor param)
  • Update tests
  • Update documentation

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions