Christophe Dongieux
04/04/2022, 2:10 PMwithTimeout
and I'd like to run unit tests to validate the behavior, but I can't make it work.
@ExperimentalCoroutinesApi
@Test
fun withTimeout() = runTest {
val result = withTimeout(1_000L) {
try{
runInterruptible {
Thread.sleep(2_000L)
Result.success(42)
}
} catch (e: Exception) {
Result.failure(e)
}
}
assert(result.isFailure) // Assertion failed
}
Do you have any idea how to make such a test succeed?