Closed
Description
The following code will raise a "This job has not completed yet" exception
@Test
fun testFuture() = runBlockingTest {
try {
CompletableFuture.supplyAsync {
Thread.sleep(1000)
throw RuntimeException("Async Exception")
}.await()
fail("Expected Exception not thrown")
} catch (e: RuntimeException) {
//noop
}
}
I believe it is because advanceUntilIdle()
doesn't wait for the future to complete because the async behaviour is kicked off from outside of the coroutines.
This may be related to some of the other "This job has not completed yet" issues, but I don't have enough experience to evaluate.