gpt4 book ai didi

c# - xUnit : Mutiple Assertions or Soft Assert

转载 作者:行者123 更新时间:2023-12-04 11:47:31 27 4
gpt4 key购买 nike

如何在 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!");
});

最佳答案

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 通常比 NUnit 更固执己见,出于意识形态原因,不会包含 NUnit 支持的内容。

关于c# - xUnit : Mutiple Assertions or Soft Assert,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59031723/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com