如何在 xUnit 中找到多个断言或软断言?我发现 Nunit 有以下能力,试图在 xUnit 中找到类似的选项。
Assert.Multiple(() =>
{
Assert.AreEqual(expectedResult1, actualResult1, "Mismatch in Score1!");
Assert.AreEqual(expectedResult2, actualResult2, "Mismatch in Score2!");
Assert.AreEqual(expectedResult3, actualResult3, "Mismatch in Score3!");
});
最佳答案
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 通常比 NUnit 更固执己见,出于意识形态原因,不会包含 NUnit 支持的内容。
关于c# - xUnit : Mutiple Assertions or Soft Assert,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59031723/