问题描述
根据 kotest 文档:https://github.com/kotest/kotest/blob/master/doc/nondeterministic.md
您可以告诉 eventually
忽略特定异常,其他任何异常都会立即通过测试。
我想将多个异常传递给最终我知道我的块会抛出的异常,以便我可以明确跳过它们。
现在我只看到一种方法来传递一个,如果块抛出这些异常,我如何将多个异常传递给 eventually
以跳过它?
解决方法
您可以对所有异常使用超类,例如
eventually(200.milliseconds,exceptionClass = RuntimeException::class) {
throw IllegalStateException()
}
或包装异常
eventually(200.milliseconds,exceptionClass = IllegalStateException::class) {
runCatching { throw UnknownError() }
.onFailure { throw IllegalStateException(it) }
}
在4.4.3
中没有异常集合的特征