TestCoroutineDispatcher

Deprecated

The execution order of `TestCoroutineDispatcher` can be confusing, and the mechanism of pausing is typically misunderstood. Please use `StandardTestDispatcher` or `UnconfinedTestDispatcher` instead.

CoroutineDispatcher that performs both immediate and lazy execution of coroutines in tests and uses a TestCoroutineScheduler 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 the dispatcher's scheduler.

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

Constructors

Link copied to clipboard
constructor(scheduler: TestCoroutineScheduler = TestCoroutineScheduler())

Properties

Link copied to clipboard

The scheduler that this dispatcher is linked to.

Functions

Link copied to clipboard

Convenience method for calling runBlockingTest on an existing TestCoroutineDispatcher.