Package kotlinx.coroutines.test

Types

DelayController
Link copied to clipboard
interface DelayController
Control the virtual clock time of a CoroutineDispatcher.
TestCoroutineDispatcher
Link copied to clipboard
CoroutineDispatcher that performs both immediate and lazy execution of coroutines in tests and implements DelayController to control its virtual clock.
TestCoroutineExceptionHandler
Link copied to clipboard
An exception handler that captures uncaught exceptions in tests.
TestCoroutineScope
Link copied to clipboard
A scope which provides detailed control over the execution of coroutines for tests.
UncaughtExceptionCaptor
Link copied to clipboard
interface UncaughtExceptionCaptor
Access uncaught coroutine exceptions captured during test execution.
UncompletedCoroutinesError
Link copied to clipboard
class UncompletedCoroutinesError(message: String, cause: Throwable?) : AssertionError
Thrown when a test has completed and there are tasks that are not completed or cancelled.

Functions

resetMain
Link copied to clipboard
fun Dispatchers.resetMain()
Resets state of the Dispatchers.Main to the original main dispatcher.
runBlockingTest
Link copied to clipboard
fun TestCoroutineDispatcher.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit)
Convenience method for calling runBlockingTest on an existing TestCoroutineDispatcher.
fun TestCoroutineScope.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit)
Convenience method for calling runBlockingTest on an existing TestCoroutineScope.
fun runBlockingTest(context: CoroutineContext = EmptyCoroutineContext, testBody: suspend TestCoroutineScope.() -> Unit)
Executes a testBody inside an immediate execution dispatcher.
setMain
Link copied to clipboard
fun Dispatchers.setMain(dispatcher: CoroutineDispatcher)
Sets the given dispatcher as an underlying dispatcher of Dispatchers.Main.
TestCoroutineScope
Link copied to clipboard
fun TestCoroutineScope(context: CoroutineContext = EmptyCoroutineContext): TestCoroutineScope
A scope which provides detailed control over the execution of coroutines for tests.