TestScope

sealed interface TestScope : CoroutineScope(source)

A coroutine scope that for launching test coroutines.

The scope provides the following functionality:

The usual way to access a TestScope is to call runTest, but it can also be constructed manually, in order to use it to initialize the components that participate in the test.

Properties

Link copied to clipboard

A scope for background work.

Link copied to clipboard
Link copied to clipboard

The delay-skipping scheduler used by the test dispatchers running the code in this scope.

Functions

Link copied to clipboard

Moves the virtual clock of this dispatcher forward by the specified amount, running the scheduled tasks in the meantime.

Link copied to clipboard

Advances the testScheduler to the point where there are no tasks remaining.

Link copied to clipboard

Run any tasks that are pending at the current virtual time, according to the testScheduler.

Link copied to clipboard
fun TestScope.runTest(dispatchTimeoutMs: Long, testBody: suspend TestScope.() -> Unit): TestResult

Performs runTest on an existing TestScope.

fun TestScope.runTest(timeout: Duration = DEFAULT_TIMEOUT.getOrThrow(), testBody: suspend TestScope.() -> Unit): TestResult

Performs runTest on an existing TestScope. See the documentation for runTest for details.