我刚接触Spock,并浏览了他们的在线文档。我有一个测试用例,需要验证我的装置与非模拟协作者的互动不会产生异常:
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
}
}
有什么想法可以帮助我完成这个任务吗?
notThrown(NullPointerException)
。 - tim_yates