mstest - 我正在为我的测试项目使用 MStest (.net core),有没有办法在失败时继续执行测试?
问题描述
我希望我的测试在断言失败后继续下一行。我试过“try catch block”,但测试没有失败。我们有什么可以在流利的断言 [https://fluentassertions.com/] 中解决这个问题的方法,或者无论如何在代码中处理这个问题?
解决方案
听起来你正在寻找 FluentAssertions 的AssertionScope。
using (new AssertionScope())
{
5.Should().Be(10); // will fail but not throw
DoSomeOtherStuff();
} // assertion will raise exception
所有失败的断言将被收集,直到AssertionScope
被处理。
推荐阅读
- ios - 使用 Alamofire 从 api 获取响应时的问题
- php - 在php中使用连接赋值运算符之前是否需要定义一个变量?
- php - 没有 slug 的 URL 重写(我正在使用 API)
- javascript - 无法通过 selenium webdriver 单击复选框。获取错误元素不可见
- php - 每行显示 3 个产品
- rust - 创建语法扩展时未解决的导入错误 E0432
- ajax - 从静态向控制器发送 HTTP 请求
- c# - C#:以字符串格式比较两个具有时间的列表值并仅提取较大的值
- typescript - TypeScript 高级类型检查
- swift - Firebase 电子邮件登录和注册,登录时不检查错误