c# - xUnit : Mutiple Assertions or Soft Assert

标签 c# specflow xunit

如何在 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/

相关文章:

visual-studio - SpecFlow 项目加载失败

c# - 在 C# 中使用 Selenium 时出现 "no such element"异常

f# - 是否可以在无需将测试代码标记为内部的情况下测试内部代码?

asp.net-core - 如何使用 ReSharper 为 DNX 项目运行 xUnit 2.1.0-beta-*

c# - 如何在控制台 C# 中清除以前的数据?

c# - 如何使用大量 CPU 快速获取线程的托管堆栈跟踪

c# - 使用值从哈希表中查找

c# - Specflow 场景大纲未生成预期的步骤代码

javascript - 模拟 IJSRuntime InvokeVoidAsync

c# - 坏主意还是好主意? WPF : Apply styles in code-behind programmatically