Suite • opensavvy.prepared.suite
Package-level declarations¶
Types¶
Prepared¶
Lazily-generated value unique to a test case.
PreparedDelegate¶
class PreparedDelegate<T>
See prepared.
PreparedDsl¶
interface PreparedDsl
PreparedDslMarker¶
@DslMarker
annotation class PreparedDslMarker
PreparedProvider¶
class PreparedProvider<T>
A Prepared is a lazily-created value that is bound to a test, such that multiple reads provide the same value.
Shared¶
Pure, immutable lazy value which is shared between all tests.
SharedDelegate¶
class SharedDelegate<T>
See shared.
SharedProvider¶
class SharedProvider<T>
A Shared is a lazily-created value that is reused between tests.
SuiteDsl¶
interface SuiteDsl : PreparedDsl
A group of tests.
TestDsl¶
interface TestDsl : PreparedDsl
A test declaration.
TestEnvironment¶
class TestEnvironment
Common utilities and features required for testing.
Time¶
class Time
Time control helper. See time.
Properties¶
backgroundScope¶
CoroutineScope for services started by this test.
clock¶
Creates a Clock that follows the virtual time in this test.
foregroundScope¶
CoroutineScope for tasks started by this test.
now¶
Access the current virtual time within this test, as an Instant.
nowMillis¶
Accesses the current time inside the test, in milliseconds.
time¶
Time control center.
Functions¶
advanceBy¶
@ExperimentalCoroutinesApi
fun Time.advanceBy(delay: Duration)
Advances the current time by delay.
advanceByMillis¶
@ExperimentalCoroutinesApi
fun Time.advanceByMillis(delay: Long)
Advances the current time by delay.
advanceUntilIdle¶
Runs all enqueued tasks in the specified order, advancing the virtual time as needed until there are no more scheduled tasks.
cleanUp¶
delayUntil¶
@ExperimentalTime
@ExperimentalCoroutinesApi
suspend fun Time.delayUntil(instant: )
Delays until the virtual time reaches instant, executing all enqueued tasks in order.
@ExperimentalTime
@ExperimentalCoroutinesApi
suspend fun Time.delayUntil(isoString: String)
Delays until the virtual time reaches isoString, formatted as an ISO 8601 timestamp, executing all enqueued tasks in order.
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.
map¶
fun <I, O> PreparedProvider<I>.map(block: (I) -> O): PreparedProvider<O>
Creates a new PreparedProvider which is the result of calling block on the input prepared provider.
prepared¶
fun <T> prepared(context: CoroutineContext = EmptyCoroutineContext, display: Display = Display.Short, block: suspend TestDsl.() -> T): PreparedProvider<T>
Declares a lazily-prepared value which will be constructed by calling block during test execution.
Declares a lazily-prepared value called name which will be constructed by calling block during test execution.
runCurrent¶
Runs all enqueued tasks at this moment in the virtual time.
runTestDsl¶
fun runTestDsl(name: String, config: TestConfig, block: suspend TestDsl.() -> Unit): TestResult
Low-level primitive to execute a test declared as a TestDsl.
runTestDslSuspend¶
suspend fun TestScope.runTestDslSuspend(name: String, config: TestConfig, block: suspend TestDsl.() -> Unit)
set¶
@ExperimentalTime
@ExperimentalCoroutinesApi
suspend fun Time.set(instant: )
Advances the virtual time until it reaches instant.
@ExperimentalTime
@ExperimentalCoroutinesApi
suspend fun Time.set(isoString: String)
Advances the virtual time until it reaches isoString, formatted as an ISO 8601 timestamp.
shared¶
fun <T> shared(context: CoroutineContext = EmptyCoroutineContext, display: Display = Display.Short, block: suspend () -> T): SharedProvider<T>
Declares a lazily-computed value that is constructed by calling block, and is then shared between all tests.