我是斯波克的新手,浏览了他们的在线文档。我有一个测试用例,需要验证我的夹具与非模拟协作者的交互不会产生异常:
class FizzSpec extends Specification {
def "no exception thrown when we hail buzz"() {
given:
Fizz fixture = new Fizz()
Buzz buzz = new Buzz("YES", true, "Garble barb") // A non-mock!
when:
fixture.hail(buzz)
// TODO: How to verify the hail didn't produce an exception?
// then:
// thrown() == null
}
}关于我如何做到这一点,有什么想法吗?
发布于 2015-08-20 20:22:46
找到了。
您可以使用
noExceptionThrown()断言什么都没有抛出
https://stackoverflow.com/questions/32126959
复制相似问题