Scala 不确定的断言

Scala inconclusive Assertion

我正在用 Scala 编写集成测试。测试从搜索配置文件开始,获取其他系统的访问信息。

如果它找到文件,那么测试应该 运行 像往常一样,但是如果它没有找到文件,我不想让测试失败,我宁愿让它不确定以表明测试无法 运行 因为缺少配置。

在 C# 中我知道 Assert.Inconclusive 这正是我想要的,在 Scala 中有类似的东西吗?

我想你在这里需要的是 assume / cancel(来自 "Assumptions" 部分,找到 here):

Trait Assertions also provides methods that allow you to cancel a test. You would cancel a test if a resource required by the test was unavailable. For example, if a test requires an external database to be online, and it isn't, the test could be canceled to indicate it was unable to run because of the missing database.