【发布时间】:2020-04-08 16:29:32
【问题描述】:
在 FluentAssertions 中断言失败后是否可以继续? 我有一些断言不是显示停止器,应该只报告但不会失败测试运行。
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
using (var scope = new AssertionScope())
{
"This Should not Failed with an AssertException".Should().Be("Should Failed");
"And this also not".Should().Be("Should Failed");
"All should only be printed to the console".Should().NotBeEmpty();
}
"But the Test should continue".Should().Be("And Failed here with an AssertException");
}
}
【问题讨论】:
-
一个小的代码示例在这里肯定会有所帮助。总的来说,不要断言不重要的事情。您可以输出一些东西,只需 google 为您的单元测试框架(例如 here 是 NUnit 方式)。
-
我正在做 Selenium 测试,如果文本不符合预期,没有理由停止测试只是为了打印一条消息。
标签: c# fluent-assertions