Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
最终在Kotlin Kotest中处理多个异常_Kotlin_Generics_Exception_Kotlin Multiplatform_Kotest - Fatal编程技术网

最终在Kotlin Kotest中处理多个异常

最终在Kotlin Kotest中处理多个异常,kotlin,generics,exception,kotlin-multiplatform,kotest,Kotlin,Generics,Exception,Kotlin Multiplatform,Kotest,根据kotest文件: 您可以告诉最终忽略特定的异常,其他任何异常都会立即导致测试失败 我希望将多个异常传递给我知道将由我的块抛出的最终异常,以便我可以显式地跳过它们 现在我只看到了传递一个异常的方法,如何将多个异常传递给最终,以在块抛出这些异常时跳过它?您可以对所有异常使用超类,如 eventually(200.milliseconds, exceptionClass = RuntimeException::class) { throw IllegalStateException() }

根据kotest文件:

您可以告诉
最终
忽略特定的异常,其他任何异常都会立即导致测试失败

我希望将多个异常传递给我知道将由我的块抛出的最终异常,以便我可以显式地跳过它们


现在我只看到了传递一个异常的方法,如何将多个异常传递给
最终
,以在块抛出这些异常时跳过它?

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

eventually(200.milliseconds, exceptionClass = RuntimeException::class) {
   throw IllegalStateException()
}
或包装异常

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

4.4.3
中,没有异常集合的功能