问题描述
在断言失败后,我希望测试继续进行下一行。我尝试了“尝试捕获块”,但测试没有失败。我们是否可以通过流畅的断言[https://fluentassertions.com/]或以任何方式通过代码来解决此问题的东西?
解决方法
您要搜索的AssertionScope的FluentAssertions声音。
using (new AssertionScope())
{
5.Should().Be(10); // will fail but not throw
DoSomeOtherStuff();
} // assertion will raise exception
所有失败的断言都将被收集,直到AssertionScope
被处理为止。