site/releases/v3/2.0.2.md
Today, we're shipping two new releases:
2.0.23.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.
These release notes are a list of changes from 2.0.1 to 2.0.2.
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#3279{: .issue-link }
We 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#3284{: .issue-link }
BUG: 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{: .issue-link } xunit/xunit#3274{: .issue-link }
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{: .issue-link }
BUG: Fixed an issue introduced in xunit/xunit#3197 where trying to pass null with the collection initialization syntax for TheoryData<T> would cause a runtime failure (throwing an ArgumentNullException). xunit/xunit#3271{: .issue-link }
BUG: There were some places where uncaught exceptions during Dispose and/or DisposeAsync which had no reporting mechanism, which could cause runners to crash. xunit/xunit#3259{: .issue-link }
BUG: 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{: .issue-link }
Added two new event assertions: Assert.RaisesAny and Assert.NotRaisedAny. The "Any" variants, like their Assert.ThrowsAny counterparts, allow any type that is compatible (rather than Assert.Raises, which has an exact type match). xunit/xunit#3239{: .issue-link }
Added 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 between expected and actual). xunit/xunit#3058{: .issue-link }