Core Framework v3 2.0.2 2025 May 3
Today, we're shipping two new releases:
- xUnit.net Core Framework v3
2.0.2
- xUnit.net Visual Studio adapter
3.1.0
(release notes)
It's been 4 weeks since the release of 2.0.1
.
As always, we'd like to thank all the users who contributed to the success of xUnit.net through usage, feedback, and code. 🎉
Note
We have updated our prototype API documentation site at https://api.xunit.net/ to include the 2.0.2 APIs. We would love feedback on the API site: whether you find it useful, what kinds of improvements we could make, etc. The ultimate goal is to have this information integrated into the main site, but for now they live on separate URLs due to different technology used to build the main site and the API site.
Release Notes
These release notes are a list of changes from 2.0.1
to 2.0.2
.
Core Framework
When running tests via
dotnet test
in Microsoft Testing Platform mode, tests which are not run due to explicit test filtering will now be reported as skipped rather than silently ignored. This should not change the behavior in Test Explorer, as those tests will still show as "not run" (or preserve their last run status) in the Test Explorer UI. xunit/xunit#3279We have made a previously internal interface (
ITypeAwareDataAttribute
) public. This attribute indicates a data attribute which would like to receive information about the reflected type of the method that it was attached to. xunit/xunit#3284BUG: Fixed an issue where source file/line number linking for tests could be missing for F# tests in Test Explorer (in Visual Studio) and C# tests in C# Dev Kit (in VS Code). xunit/xunit#3269 xunit/xunit#3274
BUG: Fixed an issue where reporting attachments in Microsoft Testing Platform mode could duplicate the file extension (if the attachment name already had the correct file extension in the name). xunit/xunit#3277
BUG: Fixed an issue introduced in xunit/xunit#3197 where trying to pass
null
with the collection initialization syntax forTheoryData<T>
would cause a runtime failure (throwing anArgumentNullException
). xunit/xunit#3271BUG: There were some places where uncaught exceptions during
Dispose
and/orDisposeAsync
which had no reporting mechanism, which could cause runners to crash. xunit/xunit#3259BUG: Fixed an issue in ArgumentFormatter which could cause a stack overflow when printing a collection with infinite recursion. This could cause issues in both printing arguments for test method display names, as well as during assertion failures. xunit/xunit#3264
Assertion Library
Added two new event assertions:
Assert.RaisesAny
andAssert.NotRaisedAny
. The "Any" variants, like theirAssert.ThrowsAny
counterparts, allow any type that is compatible (rather thanAssert.Raises
, which has an exact type match). xunit/xunit#3239Added a new equivalence assertion:
Assert.EquivalentWithExclusions
. This allows the developer to exclude some members from the equivalence comparison. There are overloads that allow passing via a lambda-expression, and via a string expression.Given this object hierarchy:
class ShallowClass { public static int StaticValue { get; set; } public int Value1; public string? Value2 { get; set; } } class DeepClass { public decimal Value3; public ShallowClass? Shallow { get; set; } }
Here is an example using lambda expressions:
[Fact] public void MixedShallowAndDeep() { Assert.EquivalentWithExclusions( new DeepClass { Value3 = 21.12m, Shallow = new ShallowClass { Value1 = 42, Value2 = "Hello" } }, new DeepClass { Value3 = 42.24m, Shallow = new ShallowClass { Value1 = 42, Value2 = "World" } }, d => d.Value3, d => d.Shallow!.Value2 ); }
And an example using string expressions:
[Fact] public void MixedShallowAndDeep() { Assert.EquivalentWithExclusions( new DeepClass { Value3 = 21.12m, Shallow = new ShallowClass { Value1 = 42, Value2 = "Hello" } }, new DeepClass { Value3 = 42.24m, Shallow = new ShallowClass { Value1 = 42, Value2 = "World" } }, "Value3", "Shallow.Value2" ); }
The lambda expression version is generic, based on the type of the
actual
value (so you can still mix types betweenexpected
andactual
). xunit/xunit#3058
Runner Utility and Runners
- Runners will now automatically disable test timeouts and long-running test detection when a debugger is attached. The console and MSBuild runners will display a message when this situation is detected. xunit/xunit#3202
NuGet Packages
- Our usage of ILRepack was not properly strong naming assemblies after re-weaving the IL. We're not aware of any issues that resulted from this, as it only affected the console and MSBuild runners (which are generally not linked to). Those assemblies will also now include their embedded PDBs, if developers need to step into the runner code (which should generally not be necessary).