我正在尝试使用PollingConditions
来期望最终会抛出异常。
then:
new PollingConditions(timeout: 3, initialDelay: 0.1, delay: 0.1).eventually {
sasClient.getSASToken(pod, targetServiceType)
thrown(NotFoundException)
}
但这会导致Groovy抱怨:Groovyc: Exception conditions are only allowed as top-level statements
是否可以测试最终会抛出异常?
答案 0 :(得分:1)
也许GroovyAssert可以帮助你,试试这个:
new PollingConditions(timeout: 3, initialDelay: 0.1, delay: 0.1).eventually {
GroovyAssert.shouldFail(NotFoundException) {
sasClient.getSASToken(pod, targetServiceType)
}
}