我正在为测试项目使用MStest.net核心,是否有办法在失败时继续执行测试?

问题描述

在断言失败后,我希望测试继续进行下一行。我尝试了“尝试捕获块”,但测试没有失败。我们是否可以通过流畅的断言[https://fluentassertions.com/]或以任何方式通过代码解决此问题的东西?

解决方法

您要搜索的AssertionScope的FluentAssertions声音。

using (new AssertionScope())
{
    5.Should().Be(10); // will fail but not throw
    DoSomeOtherStuff();
} // assertion will raise exception

所有失败的断言都将被收集,直到AssertionScope被处理为止。