turbine / app.cash.turbine / FlowTurbine

FlowTurbine

interface FlowTurbine<T>

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

Properties

timeout

Duration that expectItem, expectComplete, and expectError will wait for an event before throwing a timeout exception.

abstract val timeout: Duration

Functions

cancel

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

abstract suspend fun cancel(): Unit

cancelAndConsumeRemainingEvents

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

abstract suspend fun cancelAndConsumeRemainingEvents(): List<Event<T>>

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.

abstract suspend fun cancelAndIgnoreRemainingEvents(): Nothing

expectComplete

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

abstract suspend fun expectComplete(): Unit

expectError

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.

abstract suspend fun expectError(): Throwable

expectEvent

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

abstract suspend fun expectEvent(): Event<T>

expectItem

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.

abstract suspend fun expectItem(): T

expectNoEvents

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

abstract fun expectNoEvents(): Unit