Repository navigation
Description
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.cs—ISelfExecutingXunitTestCase.Run()callsUIXunitTestCaseRunner.Instance.Run()src/DeviceRunners.UITesting.Xunit3/UITheoryTestCase.cs— same patternsrc/DeviceRunners.UITesting.Xunit3/UIXunitTestCaseRunner.cs—RunTest()callsUIXunitTestRunner.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. RemoveAsyncSuffixdisplay option- Numeric theory row indexing for sorting
ITestMetadata.TestLabel- Native console runner as .NET Tool (
dotnet xunit-console) StartTime/FinishTimeon pipeline eventsFixtureMappingManager.InitializeAsync()withoutcreateInstancesremoved
Action Items
- Update
Directory.Packages.propsxunit.v3 versions to 4.0.0 (when stable) - Add
FixtureMappingManagerparameter to allRun()call sites - Change
overridetonewonUITheoryDiscoverer.CreateTestCasesForDataRow - Migrate
InMemoryXunit3TestFramework.CreateForAssemblytoRegisteredEngineConfig.GetTestFramework - Evaluate removing
InMemoryXunit3TestAssembly/InMemoryXunit3TestFrameworkentirely (use newassemblyPathconstructor param) - Update tests
- Update documentation
References
- Request: Make XunitTestAssembly.AssemblyPath virtual (or allow IXunitTestAssembly path injection) xunit/xunit#3577 — Assembly.Location fix
- https://xunit.net/releases/v3/4.0.0-pre.33 — First 4.0 prerelease notes
- https://xunit.net/releases/v3/4.0.0-pre.81 — Second prerelease notes
- https://xunit.net/docs/using-ci-builds — CI feed instructions
Activity
Remove xunit v3 CI feed and 4.0.0-pre.117 conditional support