Suite • opensavvy.prepared.suite • TestDsl
TestDsl¶
interface TestDsl : PreparedDsl
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…
…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¶
- cleanUpRegister a finalizer which is executed at the end of the test
Properties¶
backgroundScope¶
CoroutineScope for services started by this test.
environment¶
abstract val environment: TestEnvironment
Metadata about the running test.
foregroundScope¶
CoroutineScope for tasks started by this test.
Random¶
See random.
random¶
Random generator control center.
time¶
Time control center.
Functions¶
cleanUp¶
immediate¶
Realizes a Prepared value from the provided PreparedProvider.
invoke¶
Realizes a Prepared value in the context of this test.
launch¶
fun TestDsl.launch(context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit): Job
Starts a task in the foregroundScope. The test will wait for this task before finishing.
launchInBackground¶
fun TestDsl.launchInBackground(context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit): Job
Starts a task in the backgroundScope scope. The test will not wait for this task before finishing.