我要迁移到Specs2 2。
这用于编译
if(foo) {
bar mustBe equalTo(1)
} else {
skipped("foo was false")
}但现在不再是
could not find implicit value for evidence parameter of type org.specs2.execute.AsResult[Object]我该怎么办?
版本2.3.13
发布于 2014-08-06 23:04:15
第一行返回Matcher[T],第二行返回Result。这两个类型统一为Object,这就是您获得这样一个编译消息的原因。
要解决这个问题,您可以使用以下助手函数:
def skipWhen[R : AsResult](condition: Boolean, message)(r: =>R): Result =
if (condition) skipped(message)
else AsResult(r)
"my example" >> skipWhen(serverIsDown, "server is down") {
1 must_== 1
}还有其他方法可以跳过用户指南中描述的示例
"my example is skipped" >> skipped {
sys.error("boom")
ok
}
"this will skip if the expectation is false" >> {
1 must beEqualTo(2).orSkip
}
"this will succeed if the condition is false" >> {
1 must beEqualTo(2).unless(condition)
}
// this will skip all the examples in the specification if the condition is true
skipAllIf(condition)https://stackoverflow.com/questions/25149606
复制相似问题