Table of Contents

Core Framework v3 4.0.0-pre.108 2026 May 2

Today, we're shipping two new prereleases:

  • xUnit.net Core Framework v3 4.0.0-pre.108
  • xUnit.net Analyzers 2.0.0-pre.51 (release notes)

This is the third prerelease build for the 4.0 release. This is anticipated to be the final prerelease of this cycle, so please focus testing efforts to find any remaining issues before we ship an RTW.

As always, we'd like to thank all the users who contributed to the success of xUnit.net through usage, feedback, and code. 🎉

Note

With 4.0, we are discontinuing official support for Microsoft Testing Platform v1. The default version of Microsoft Testing Platform support now is v2 (currently at version 2.2.1), and we will continue to offer packages to turn off Microsoft Testing Platform support as well.

Note

With 4.0, we are discontinuing official support for Mono. While we anticipate that it will usually continue to work, we have noticed occasional Mono-related issues in our own CI process. Given that Mono is now abandoned, we don't anticipate being able to get any support for resolving them. Any requests for xUnit.net support for Mono-related issues will be declined. We may accept bug fixes based on their severity and the impact to the codebase.

Release Notes

These release notes are a list of changes from 4.0.0-pre.81 to 4.0.0-pre.108.

Core Framework

  • We have added support for fixtures to get notified of test execution pipeline events.

    Interface Usable by
    INotifyTestAssemblyLifecycle
    INotifyTestAssemblyLifecycleAsync
    Assembly fixtures
    INotifyTestCollectionLifecycle
    INotifyTestCollectionLifecycleAsync
    Assembly and collection fixtures
    INotifyTestClassLifecycle
    INotifyTestClassLifecycleAsync
    Assembly, collection, and class fixtures
    INotifyTestMethodLifecycle
    INotifyTestMethodLifecycleAsync
    Assembly, collection, and class fixtures
    INotifyTestCaseLifecycle
    INotifyTestCaseLifecycleAsync
    Assembly, collection, and class fixtures
    INotifyTestLifecycle
    INotifyTestLifecycleAsync
    Assembly, collection, and class fixtures

    Any fixture class can implement one or more of these interfaces, and they will be called when the test execution pipeline is underway.

    An example of where this might be useful: A fixture would like to create and tear down a database at its normal lifecycle point (for example, a shared database as a collection fixture would create the database when the collection starts, and tear it down when the collection ends). I would also like to reset the data in the database before each test begins. The fixture itself is injectable into the test class via constructor so that the test can be access to the connection information for the test database.

    The test-level events are similar in timing today with what's possible via [BeforeAfterTestAttribute], except that this also supports asynchronous operations (the attribute only supports synchronous). xunit/xunit#3504 xunit/xunit#3528

  • We have extended ITypeActivator to be used for fixture creation (in reflection mode). This should extend dependency injection-like capabilities to fixtures (in addition to test classes). xunit/xunit#3567

  • We have added two new MSBuild properties:

    NuGet package $(XunitTestProject) $(XunitTestProjectAOT)
    xunit.v3.core
    xunit.v3.core.mtp-v2
    xunit.v3.core.mtp-off
    true
    true
    true
    xunit.v3.core.aot
    xunit.v3.core.aot.mtp-v2
    xunit.v3.core.aot.mtp-off
    true
    true
    true
    true
    true
    true

    The purpose of these properties is to provide developers with the ability to trigger behavior off knowing whether they're being used in the context of an xUnit.net test project, which can be useful when mixing multiple Microsoft Testing Platform enabled test frameworks.

    These MSBuild properties are only set by the above named packages to correlate with test projects (in particular, they are not set when referencing xunit.v3.extensibility.core, which correlates with extensibility projects). microsoft/testfx#7773

  • BUG: F# projects were not able to build in Microsoft Testing Platform UX command line mode due to incorrect spacing in the generated entrypoint source file. xunit/xunit#3547

  • BUG: TestContext.Current.CancellationToken and TestContext.Current.CancelCurrentTest() were throwing when the test context had been disposed. Now, these operations either return a default CancellationToken or are ignored. xunit/xunit#3554

  • BUG: Debugger detection was moved from discovery time to execution time. This issue manifested as debugger-specific behavior not working when using VSTest inside Visual Studio's Test Explorer (for example, tests with timeouts would still run their timeouts, which is behavior that is normally disabled when running under a debugger). xunit/visualstudio.xunit#450

Assertion Library

  • We have added the ability to override the way assertion messages are formatted on a per-test basis. This includes:

    • Assert.OverrideMaxEnumerableLength
      Changes the number of items to display in an enumerable/collection
    • Assert.OverrideMaxObjectDepth
      Changes the depth to recurse into complex objects when printing them
    • Assert.OverrideMaxObjectMemberCount
      Changes the number of members to show when printing a complex object
    • Assert.OverrideMaxStringLength
      Changes the length of strings to print before truncation
    Note

    OverrideMaxObjectDepth and OverrideMaxObjectMemberCount have no effect in Native AOT mode, since the assertion results do not print complex objects in Native AOT (due to reflection limitations).

    Setting these overrides uses AsyncLocal functionality, so the override only affects the current test in which the override is set. Attempting to override these values outside of a test method is not supported, and may have unanticipated consequences (may affect an unknown set of tests). xunit/xunit#3526

Native AOT

  • BUG: The source generator was incorrectly trying to generate code to call [Fact] tests with parameters. It now correctly skips this. xunit/xunit#3543

  • BUG: There was a compiler ambiguity with calls to DataAttributeRegistration.CreateDataRow for data attribute source generation. [OverloadResolutionPriority] was added to resolve this. xunit/xunit#3546

  • BUG: Numeric constants in [InlineData] could lose their type, causing casting failures at runtime when trying to run the theory. xunit/xunit#3548

  • BUG: Generated default values in [InlineData] were incorrectly cased (e.g., False instead of false) or typed (e.g., c instead of 'c'), causing compiler failures. xunit/xunit#3549 xunit/xunit#3550

  • BUG: The type registration for unbound generic types was incorrect, and has been updated. It was previously global::Namespace.TypeName<T>, and now is global::Namespace.TypeName<>. This affected data attributes ([InlineData], [MemberData], and [ClassData]) inside open generic abstract base test classes. xunit/xunit#3556

  • BUG: Assembly fixures were not being properly resolved in test classes, due to incorrectly generated registration source code. xunit/xunit#3563

Runner Common / Runner Utility

  • We have updated the logic used to sanitize attachment filenames to always exclude all invalid characters from Windows, Linux, and macOS (rather than just the ones from the current OS). This better supports scenarios where attachment files are generated on one OS and then copied to another (e.g., in CI build scenarios). xunit/xunit#3561

  • We have added a settable InProcessTestProcessLauncher.LoadContext (of type AssemblyLoadContext) to be used when the in-process launcher loads the test assembly. This property is only available in .NET 8+ (and not in .NET Framework). xunit/xunit#3559

Microsoft Testing Platform

  • The MTP v2 packages have been updated to Microsoft Testing Platform 2.2.2.

  • We have added --filter, which accepts the older VSTest filter syntax. This should aid users who are porting from VSTest to Microsoft Testing Platform. xunit/xunit#3466

  • The output folder for attachments is now the results directory (which can be overridden with --results-directory). Previously these were being written into the temp folder. xunit/xunit#3562

  • We are setting MSBuild property <IsTestingPlatformApplication>true</IsTestingPlatformApplication> in anticipation of a potentially breaking change coming in Microsoft Testing Platform v3. microsoft/testfx#7665