ServiceImpl
def "異常系"() {
setup:
// service.createBody(_ as boolean) >> { throw new RuntimeException("dummy") }
service.createBody(_) >> { throw new RuntimeException("dummy") }
when:
String testString = service.send(to, hash)
then:
RuntimeException e = thrown()
e.getMessage() == expected
where:
testcase | to | hash | expected
"test" | "aaa@co.jp" | "testhash" | "dummy"
}
IntelliJでservice.createBody(_)の_
の部分が黄色くなってていつも補完してたけど
_
だけならしっかりExceptionが発生してくれる。
booleanのときは特殊なのかな?
無理やりException発生させたいときは覚えておくと便利かも