TestScope
A coroutine scope that for launching test coroutines.
The scope provides the following functionality:
The coroutineContext includes a coroutine dispatcher that supports delay-skipping, using a TestCoroutineScheduler for orchestrating the virtual time. This scheduler is also available via the testScheduler property, and some helper extension methods are defined to more conveniently interact with it: see TestScope.currentTime, TestScope.runCurrent, TestScope.advanceTimeBy, and TestScope.advanceUntilIdle.
When inside runTest, uncaught exceptions from the child coroutines of this scope will be reported at the end of the test. It is invalid for child coroutines to throw uncaught exceptions when outside the call to TestScope.runTest: the only guarantee in this case is the best effort to deliver the exception.
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
A scope for background work.
The current virtual time on testScheduler.
The delay-skipping scheduler used by the test dispatchers running the code in this scope.
Functions
Moves the virtual clock of this dispatcher forward by the specified amount, running the scheduled tasks in the meantime.
Advances the testScheduler to the point where there are no tasks remaining.
Run any tasks that are pending at the current virtual time, according to the testScheduler.