Package-level declarations

Types

Link copied to clipboard
sealed interface Event<out T>
Link copied to clipboard
interface ReceiveTurbine<T>
Link copied to clipboard
interface Turbine<T> : ReceiveTurbine<T>

A standalone Turbine suitable for usage in fakes or other external test components.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
suspend fun <T> ReceiveChannel<T>.awaitComplete(name: String? = null)

Assert that attempting to read from the ReceiveChannel yields ClosedReceiveChannelException, indicating that it was closed without an exception.

Link copied to clipboard
suspend fun <T> ReceiveChannel<T>.awaitError(name: String? = null): Throwable

Assert that attempting to read from the ReceiveChannel yields an exception, indicating that it was closed with an exception.

Link copied to clipboard
suspend fun <T> ReceiveChannel<T>.awaitEvent(name: String? = null): Event<T>

Assert that an event was received and return it. This function will suspend if no events have been received.

Link copied to clipboard
suspend fun <T> ReceiveChannel<T>.awaitItem(name: String? = null): T

Assert that the next event received was an item and return it. This function will suspend if no events have been received.

Link copied to clipboard

Returns the most recent item that has already been received. If channel was closed with no item being received previously, this function will throw an AssertionError. If channel was closed with an exception, this function will throw the underlying exception.

Link copied to clipboard
fun <T> ReceiveChannel<T>.expectNoEvents(name: String? = null)

Assert that there are no unconsumed events which have already been received.

Link copied to clipboard
operator fun <T> Turbine<T>.plusAssign(value: T)
Link copied to clipboard
suspend fun <T> ReceiveChannel<T>.skipItems(count: Int, name: String? = null)

Assert that count item events were received and ignore them. This function will suspend if no events have been received.

Link copied to clipboard
fun <T> ReceiveChannel<T>.takeComplete(name: String? = null)

Assert that the next event received is Event.Complete. This function will not suspend. On JVM and Android, it will attempt to throw if invoked in a suspending context.

Link copied to clipboard
fun <T> ReceiveChannel<T>.takeError(name: String? = null): Throwable

Assert that the next event received is Event.Error, and return the error. This function will not suspend. On JVM and Android, it will attempt to throw if invoked in a suspending context.

Link copied to clipboard
fun <T> ReceiveChannel<T>.takeEvent(name: String? = null): Event<T>

Assert that the next event received was non-null and return it. This function will not suspend. On JVM and Android, it will attempt to throw if invoked in a suspending context.

Link copied to clipboard
fun <T> ReceiveChannel<T>.takeItem(name: String? = null): T

Assert that the next event received was an item and return it. This function will not suspend. On JVM and Android, it will attempt to throw if invoked in a suspending context.

Link copied to clipboard
suspend fun <T> Flow<T>.test(timeout: Duration? = null, name: String? = null, validate: suspend TurbineTestContext<T>.() -> Unit)

Terminal flow operator that collects events from given flow and allows the validate lambda to consume and assert properties on them in order. If any exception occurs during validation the exception is rethrown from this method.

Link copied to clipboard
fun <T> Flow<T>.testIn(scope: CoroutineScope, timeout: Duration? = null, name: String? = null): ReceiveTurbine<T>

Terminal flow operator that collects events from given flow and returns a ReceiveTurbine for consuming and asserting properties on them in order. If any exception occurs during validation the exception is rethrown from this method.

Link copied to clipboard
fun <T> Turbine(timeout: Duration? = null, name: String? = null): Turbine<T>

Construct a standalone Turbine.

Link copied to clipboard
suspend fun turbineScope(timeout: Duration? = null, validate: suspend TurbineContext.() -> Unit)

Run a validation block that catches and reports all unhandled exceptions in flows run by Turbine.

Link copied to clipboard
suspend fun <T> withTurbineTimeout(timeout: Duration, block: suspend CoroutineScope.() -> T): T

Sets a timeout for all Turbine instances within this context. If this timeout is not set, the default value is 3sec.