TestFlowObserver

class TestFlowObserver<T>(flow: Flow<T>)

Allows you to record all observed values of a flow for easy testing.

Parameters

flow

The flow to observe.

Constructors

TestFlowObserver
Link copied to clipboard
fun <T> TestFlowObserver(flow: Flow<T>)

Types

Companion
Link copied to clipboard
object Companion

Functions

awaitCount
Link copied to clipboard
fun awaitCount(count: Int, timeout: Long = 5000L)

Awaits until the specified count of elements has been received or the timeout is hit.

awaitCountSuspending
Link copied to clipboard
suspend fun awaitCountSuspending(count: Int, timeout: Long = 5000L)

Awaits until the specified count of elements has been received or the timeout is hit.

awaitFor
Link copied to clipboard
suspend fun awaitFor(timeout: Long = 5000L, condition: TestFlowObserver<T>.() -> Boolean)

Awaits until the specified condition is fulfilled or the timeout is hit.

close
Link copied to clipboard
fun close()

Closes the subscription on the underlying stream. No further values will be received after this call.

Properties

values
Link copied to clipboard
val values: List<T>

Sources

common source
Link copied to clipboard