How can I find Multiple Assertions or Soft Assert in xUnit? I found Nunit has below ability, trying to find similar options in xUnit.
Assert.Multiple(() =>
{
Assert.AreEqual(expectedResult1, actualResult1, "Mismatch in Score1!");
Assert.AreEqual(expectedResult2, actualResult2, "Mismatch in Score2!");
Assert.AreEqual(expectedResult3, actualResult3, "Mismatch in Score3!");
});
As of xUnit 2, it does not exist.
There are plenty of things we could do, but for many reasons we choose not to. This reasons include: (a) implementation and maintenance cost; (b) competing priorities; (c) philosophical objections to features.
In this case, you're running afoul of (c). We do not believe that a unit testing framework should ever run more than one failing assertion.
xUnit is in general much more opinionated than NUnit, and won't include things which NUnit supports, for ideological reasons.
It looks like xUnit 3 will support this, using Assert.Multiple
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With