Package-level declarations

Types

Link copied to clipboard
class Prepared<out T>

Lazily-generated value unique to a test case.

Link copied to clipboard
Link copied to clipboard
interface PreparedDsl
Link copied to clipboard
annotation class PreparedDslMarker
Link copied to clipboard

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

Link copied to clipboard
class Random

Random control helper. See random.

Link copied to clipboard
class Shared<out T>

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

Link copied to clipboard
Link copied to clipboard

A Shared is a lazily-created value that is reused between tests.

Link copied to clipboard
interface SuiteDsl : PreparedDsl

A group of tests.

Link copied to clipboard
interface TestDsl : PreparedDsl

A test declaration.

Link copied to clipboard

Common utilities and features required for testing.

Link copied to clipboard
class Time

Time control helper. See time.

Properties

Link copied to clipboard

CoroutineScope for services started by this test.

Link copied to clipboard

CoroutineScope for tasks started by this test.

Link copied to clipboard

Accesses the current time inside the test, in milliseconds.

Link copied to clipboard
@get:JvmName(name = "getKotlinRandom")
val TestDsl.Random: Random

See random.

Link copied to clipboard

Random generator control center.

Link copied to clipboard

Functions

Link copied to clipboard

Advances the current time by delay.

Link copied to clipboard

Advances the current time by delay.

Link copied to clipboard

Runs all enqueued tasks in the specified order, advancing the virtual time as needed until there are no more scheduled tasks.

Link copied to clipboard
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.

Link copied to clipboard
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.

Link copied to clipboard
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.

Link copied to clipboard
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.

Link copied to clipboard
suspend fun Random.nextBits(bitCount: Int): Int

Generates random bits.

Link copied to clipboard
suspend fun Random.nextBoolean(): Boolean

Generates a random boolean.

Link copied to clipboard
suspend fun Random.nextDouble(): Double
suspend fun Random.nextDouble(from: Double, until: Double): Double

Generates a random double.

Link copied to clipboard
suspend fun Random.nextFloat(): Float

Generates a random float.

Link copied to clipboard
suspend fun Random.nextInt(): Int
suspend fun Random.nextInt(from: Int, until: Int): Int

Generates a random integer.

Link copied to clipboard
suspend fun Random.nextLong(): Long
suspend fun Random.nextLong(from: Long, until: Long): Long

Generates a random integer.

Link copied to clipboard
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.

Link copied to clipboard

Provider for random bits.

Link copied to clipboard

Provider for a random boolean.

Link copied to clipboard

Provider for a random double.

Link copied to clipboard

Provider for a random float.

Link copied to clipboard
fun randomInt(from: Int, until: Int): PreparedProvider<Int>

Provider for a random integer.

Link copied to clipboard

Provider for a random integer.

Link copied to clipboard

Runs all enqueued tasks at this moment in the virtual time.

Link copied to clipboard
fun runTestDsl(name: String, context: CoroutineContext, config: TestConfig, block: suspend TestDsl.() -> Unit): TestResult

Low-level primitive to execute a test declared as a TestDsl.

Link copied to clipboard
suspend fun TestScope.runTestDslSuspend(name: String, context: CoroutineContext, config: TestConfig, block: suspend TestDsl.() -> Unit)

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

Link copied to clipboard
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.