-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
docsKDoc and API referenceKDoc and API reference
Description
Context:
The current documentation is unclear about how delay behaves when using UnconfinedTestDispatcher.
The phrase “it skips delays” can reasonably be interpreted as delayed coroutines resuming immediately when delay() is called inside the coroutine block.
The actual execution semantics are not clearly described, and this part of the documentation could be improved.
Page:
Section:
This dispatcher is similar to Dispatchers.Unconfined: the tasks that it executes are not confined to any particular thread and form an event loop; it's different in that it skips delays, as all TestDispatchers do.
Test:
@Test
fun unconfinedTestDispatcherDelay() = runTest {
val dispatcher = UnconfinedTestDispatcher(testScheduler)
var resumed = false
launch(dispatcher) {
delay(100)
resumed = true
}
// At this point, resumed is false
assertFalse(resumed)
testScheduler.advanceUntilIdle()
assertTrue(resumed)
}Metadata
Metadata
Assignees
Labels
docsKDoc and API referenceKDoc and API reference