TestCoroutineScope

@ExperimentalCoroutinesApi interface TestCoroutineScope : 
    CoroutineScope,
    UncaughtExceptionCaptor,
    DelayController

A scope which provides detailed control over the execution of coroutines for tests.

Inherited Properties

currentTime

abstract val currentTime: Long

Returns the current virtual clock-time as it is known to this Dispatcher.

uncaughtExceptions

abstract val uncaughtExceptions: List<Throwable>

List of uncaught coroutine exceptions.

Functions

cleanupTestCoroutines

abstract fun cleanupTestCoroutines(): Unit

Call after the test completes. Calls UncaughtExceptionCaptor.cleanupTestCoroutines and DelayController.cleanupTestCoroutines.

Inherited Functions

advanceTimeBy

abstract fun advanceTimeBy(delayTimeMillis: Long): Long

Moves the Dispatcher’s virtual clock forward by a specified amount of time.

advanceUntilIdle

abstract fun advanceUntilIdle(): Long

Immediately execute all pending tasks and advance the virtual clock-time to the last delay.

pauseDispatcher

abstract suspend fun pauseDispatcher(
    block: suspend () -> Unit
): Unit

Run a block of code in a paused dispatcher.

abstract fun pauseDispatcher(): Unit

Pause the dispatcher.

resumeDispatcher

abstract fun resumeDispatcher(): Unit

Resume the dispatcher from a paused state.

runCurrent

abstract fun runCurrent(): Unit

Run any tasks that are pending at or before the current virtual clock-time.

Extension Functions

runBlockingTest

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

Convenience method for calling runBlockingTest on an existing TestCoroutineScope.