Package kotlinx.coroutines.test

Types

DelayController

interface DelayController

Control the virtual clock time of a CoroutineDispatcher.

TestCoroutineDispatcher

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.

TestCoroutineExceptionHandler

class TestCoroutineExceptionHandler : 
    UncaughtExceptionCaptor,
    CoroutineExceptionHandler

An exception handler that captures uncaught exceptions in tests.

TestCoroutineScope

interface TestCoroutineScope : 
    CoroutineScope,
    UncaughtExceptionCaptor,
    DelayController

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

UncaughtExceptionCaptor

interface UncaughtExceptionCaptor

Access uncaught coroutine exceptions captured during test execution.

Exceptions

UncompletedCoroutinesError

class UncompletedCoroutinesError : AssertionError

Thrown when a test has completed and there are tasks that are not completed or cancelled.

Extensions for External Classes

kotlinx.coroutines.Dispatchers

Functions

TestCoroutineScope

fun TestCoroutineScope(
    context: CoroutineContext = EmptyCoroutineContext
): TestCoroutineScope

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

runBlockingTest

fun runBlockingTest(
    context: CoroutineContext = EmptyCoroutineContext,
    testBody: suspend TestCoroutineScope.() -> Unit
): Unit

Executes a testBody inside an immediate execution dispatcher.

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

Convenience method for calling runBlockingTest on an existing TestCoroutineScope.

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

Convenience method for calling runBlockingTest on an existing TestCoroutineDispatcher.