2

As per kotest docs: https://github.com/kotest/kotest/blob/master/doc/nondeterministic.md

You can tell eventually to ignore specific exceptions and any others will immediately fail the test.

I want to pass multiple exceptions to eventually that I know would be thrown by my block so that I can explicitly skip them.

Right now I only see a way to pass one, how do I pass more than one exception to eventually to skip it in case the block throws those exceptions?

4

1 回答 1

0

您可以对所有异常使用超类,例如

eventually(200.milliseconds, exceptionClass = RuntimeException::class) {
   throw IllegalStateException()
}

或包装异常

eventually(200.milliseconds, exceptionClass = IllegalStateException::class) {
    runCatching { throw UnknownError() }
        .onFailure { throw IllegalStateException(it) }
}

4.4.3没有具有异常集合的功能

于 2021-04-30T05:33:44.127 回答