TestDsl
A test declaration.
This interface is most often used as a test declaration: suspend TestDsl.() -> Unit
.
Tests allow to control the time. For more information, read time.
Design notes
It is our goal to keep this interface as lightweight as possible, because any field we add here risks being shadowed by local variables in the tests.
For example, if we were to add a member called foo
, then this code…
test("Test") {
val foo = …
}
…shadows the member 'foo'.
Instead, we add all fields to TestEnvironment, and create extension functions which expose the most important functionality.
Note to runner implementors
If you are implementing your own test runner, you will need to provide an instance of this interface. Because it encapsulates the whole test machinery, we recommend using runTestDsl instead of making your own implementation.
See also
Register a finalizer which is executed at the end of the test
Properties
CoroutineScope for services started by this test.
Metadata about the running test.
CoroutineScope for tasks started by this test.
Time control center.
Functions
Realizes a Prepared value from the provided PreparedProvider.
Starts a task in the foregroundScope. The test will wait for this task before finishing.
Starts a task in the backgroundScope scope. The test will not wait for this task before finishing.