Table of Contents

Core Framework v2 2.7.0 2024 February 15

Today, we're shipping three new releases:

  • xUnit.net Core Framework v2 2.7.0
  • xUnit.net Analyzers 1.11.0 (release notes)
  • xUnit.net Visual Studio adapter 2.5.7 (release notes)

It's been 1 month since the release of 2.6.6.

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

Release Notes

These release notes are a comprehensive list of changes from 2.6.6 to 2.7.0.

Core Framework

  • We have fixed a binary breaking change to SynchronousMessageBus caused by a constructor change. The old constructor has been restored and marked as [Obsolete].

Runner Utility

  • We have added a ConfigWarnings property to XunitProjectAssembly which will contain warnings related to unsupported configuration file types, files which cannot be found/loaded, JSON config files which are malformed, or any time an exception is thrown while loading/parsing configuration. It is the responsibility of the runner to find an appropriate place to report these warnings. We have updated all the first party runners (xunit.runner.console, xunit.runner.msbuild, xunit.runner.tdnet, and xunit.runner.visualstudio) to report these. xunit/xunit#1655

  • We will only use our AsyncTestSyncContext for tests marked as async void. This may provide a slight performance improvement for some users. xunit/xunit#2573

  • We will now fail any test which is marked with [Fact(Timeout = n)] if the test is not async. Previously this resulted in behavior where the timeout was ignored.

Assertion Library

  • We have added support for IAsyncEnumerable<T> in the following assertions:

    • Assert.All
    • Assert.AllAsync
    • Assert.Collection
    • Assert.CollectionAsync
    • Assert.Contains
    • Assert.Distinct
    • Assert.DoesNotContain
    • Assert.Empty
    • Assert.Equal
    • Assert.NotEqual
    • Assert.Single

    For developers taking a binary NuGet dependency (the typical way), you must be using .NET 6 or later to get these new overloads. If you are importing our assertions via source (either as NuGet or via Git submodule), you must be using .NET Core 3.0 or later. In addition, developers importing via source can also take advantage of AssertHelper.ToEnumerable() to convert an async enumerable into a standard enumerable.

  • We have updated Assert.Contains and Assert.DoesNotContain to extend our special handling of sets from just the concrete HashSet<T> to any class which implements ISet<T>. We also extend this support to any class which implements IReadOnlySet<T>, if you are using .NET 6 or later (via binary NuGet dependency) or .NET 5 or later (via source dependency).

  • We have updated the XML documentation around the assertions that take Span<char> and ReadOnlySpan<char> to indicate that these assertion treat the spans like strings rather than like collections of characters. While this has always been true, the documentation did not make that clear previously. We have also updated the documentation for the overloads that can ignore white-space to include a complete list of the characters that we consider white-space (there are 21 separate characters that we consider white-space at the time of this release).

  • We have updated reporting in Assert.Equal and Assert.NotEqual, when showing type names, if the type is a compiler generated type we simply now display <generated> rather than the mangled auto-generated type name.

  • BUG: We have fixed an issue with Assert.Collection where the inner stack trace was no longer being displayed, making it difficult to know which precise line of code caused the comparison failure. xunit/xunit#2871