Skip to content

runBlockingTest raises job has not completed yet with Futures #1395

Closed
@powturns

Description

@powturns

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions