TestCoroutineDispatcher

@ExperimentalCoroutinesApi class TestCoroutineDispatcher : 
    CoroutineDispatcher,
    Delay,
    DelayController

CoroutineDispatcher that performs both immediate and lazy execution of coroutines in tests and implements DelayController to control its virtual clock.

By default, TestCoroutineDispatcher is immediate. That means any tasks scheduled to be run without delay are immediately executed. If they were scheduled with a delay, the virtual clock-time must be advanced via one of the methods on DelayController.

When switched to lazy execution using pauseDispatcher any coroutines started via launch or async will not execute until a call to DelayController.runCurrent or the virtual clock-time has been advanced via one of the methods on DelayController.

See Also

DelayController

Constructors

<init>

TestCoroutineDispatcher()

CoroutineDispatcher that performs both immediate and lazy execution of coroutines in tests and implements DelayController to control its virtual clock.

Extension Functions

runBlockingTest

fun TestCoroutineDispatcher.runBlockingTest(
    block: suspend TestCoroutineScope.() -> Unit
): <ERROR CLASS>

Convenience method for calling runBlockingTest on an existing TestCoroutineDispatcher.