我是否可以在 scalaTest规范之间存在依赖关系,以便在测试失败时,将跳过所有依赖于它的测试? 我没有添加TestNG的这个功能,因为我当时没有任何引人注目的用例来证明它的合理性.我已经
与此同时,您可以使用Scala if语句仅在条件满足时注册测试,或者如果您希望看到输出,则将它们注册为忽略.如果您使用Spec,它看起来像:
if (databaseIsAvailable) {
it("should do something that requires the database") {
// ...
}
it ("should do something else that requires the database") {
}
}
这仅在测试施工时确保满足条件时才有效.例如,如果数据库应该由beforeAll方法启动,那么您可能需要在每个测试中进行检查.在那种情况下,你可以说它正在等待.就像是:
it("should do something that requires the database") {
if (!databaseIsAvailable) pending
// ...
}
it("should do something else that requires the database") {
if (!databaseIsAvailable) pending
// ...
}
