FlowTurbine

interface FlowTurbine<T>

Represents active collection on a source Flow which buffers item emissions, completion, and/or errors as events for consuming.

Functions

awaitComplete
Link copied to clipboard
abstract suspend fun awaitComplete()

Assert that the next event received was the flow completing. If no events have been received, this function will suspend for up to timeout.

awaitError
Link copied to clipboard
abstract suspend fun awaitError(): Throwable

Assert that the next event received was an error terminating the flow. If no events have been received, this function will suspend for up to timeout.

awaitEvent
Link copied to clipboard
abstract suspend fun awaitEvent(): Event<T>

Assert that an event was received and return it. If no events have been received, this function will suspend for up to timeout.

awaitItem
Link copied to clipboard
abstract suspend fun awaitItem(): T

Assert that the next event received was an item and return it. If no events have been received, this function will suspend for up to timeout.

cancel
Link copied to clipboard
abstract fun cancel()

Cancel collecting events from the source Flow. Any events which have already been received will still need consumed using the "await" functions.

cancelAndConsumeRemainingEvents
Link copied to clipboard
abstract fun cancelAndConsumeRemainingEvents(): List<Event<T>>

Cancel collecting events from the source Flow. Any events which have already been received will be returned.

cancelAndIgnoreRemainingEvents
Link copied to clipboard
abstract fun cancelAndIgnoreRemainingEvents(): Nothing

Cancel collecting events from the source Flow and ignore any events which have already been received. Calling this function will exit the test block.

expectMostRecentItem
Link copied to clipboard
abstract fun expectMostRecentItem(): T

Returns the most recent item that has already been received. If a complete event has been received with no item being received previously, this function will throw an AssertionError. If an error event has been received, this function will throw the underlying exception.

expectNoEvents
Link copied to clipboard
abstract fun expectNoEvents()

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

Properties

timeoutMs
Link copied to clipboard
abstract val timeoutMs: Long

Duration in milliseconds that awaitItem, awaitComplete, awaitError, and awaitEvent will wait before throwing a timeout exception.

Extensions

timeout
Link copied to clipboard
val FlowTurbine<*>.timeout: Duration

Duration that awaitItem, awaitComplete, awaitError, and awaitEvent will wait before throwing a timeout exception.