Skip to content

Suiteopensavvy.prepared.suite

Package-level declarations

Types

Prepared

class Prepared<out T>

Lazily-generated value unique to a test case.

PreparedDelegate

See prepared.

PreparedDsl

interface PreparedDsl

PreparedDslMarker

@DslMarker
annotation class PreparedDslMarker

PreparedProvider

A Prepared is a lazily-created value that is bound to a test, such that multiple reads provide the same value.

Shared

class Shared<out T>

Pure, immutable lazy value which is shared between all tests.

SharedDelegate

See shared.

SharedProvider

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

Common utilities and features required for testing.

Time

class Time

Time control helper. See time.

Properties

backgroundScope

CoroutineScope for services started by this test.

foregroundScope

CoroutineScope for tasks started by this test.

nowMillis

Accesses the current time inside the test, in milliseconds.

time

Time control center.

Functions

advanceBy

Advances the current time by delay.

advanceByMillis

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

suspend fun TestDsl.cleanUp(name: String, onSuccess: Boolean = true, onFailure: Boolean = true, block: suspend TestDsl.() -> Unit)

Registers a block named name to run at the end of the 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.

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.

fun <I, O> Prepared<I>.map(name: String, block: (I) -> O): Prepared<O>

Creates a new Prepared which is the result of calling block on the input prepared value.

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.

fun <T> prepared(name: String, context: CoroutineContext = EmptyCoroutineContext, display: Display = Display.Short, block: suspend TestDsl.() -> T): Prepared<T>

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)

Low-level primitive to execute a test declared as a TestDsl, when already inside a TestScope.

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.

fun <T> shared(name: String, context: CoroutineContext = EmptyCoroutineContext, display: Display = Display.Short, block: suspend () -> T): Shared<T>

Declares a lazily-computer value called name that is constructed by calling block, and is then shared between all tests.