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

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

Types

Link copied to clipboard
object Companion

Functions

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

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

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

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

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

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

Link copied to clipboard
fun close()

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

Properties

Link copied to clipboard
val values: List<T>

Sources

Link copied to clipboard