FlowTurbine

interface FlowTurbine<T>

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

Functions

Link copied to clipboard
abstract suspend fun awaitComplete()

Assert that the next event received was the flow completing. This function will suspend if no events have been received.

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

Assert that the next event received was an error terminating the flow. This function will suspend if no events have been received.

Link copied to clipboard
abstract suspend fun awaitEvent(): 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
abstract suspend fun awaitItem(): 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
abstract suspend fun cancel()

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

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

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

Link copied to clipboard
abstract suspend fun cancelAndIgnoreRemainingEvents()

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

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.

Link copied to clipboard
abstract fun expectNoEvents()

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

Link copied to clipboard
abstract suspend fun skipItems(count: Int)

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