test
suspend fun <T> Flow<T>.test(timeout: Duration? = null, name: String? = null, validate: suspend ReceiveTurbine<T>.() -> Unit)
Terminal flow operator that collects events from given flow and allows the validate lambda to consume and assert properties on them in order. If any exception occurs during validation the exception is rethrown from this method.
flowOf("one", "two").test {
assertEquals("one", expectItem())
assertEquals("two", expectItem())
awaitComplete()
}
Content copied to clipboard
Parameters
timeout
If non-null, overrides the current Turbine timeout inside validate. See also: withTurbineTimeout.