test In
fun <T> Flow<T>.testIn(scope: CoroutineScope, timeout: Duration? = null, name: String? = null): ReceiveTurbine<T>
Terminal flow operator that collects events from given flow and returns a ReceiveTurbine for consuming and asserting properties on them in order. If any exception occurs during validation the exception is rethrown from this method.
val turbine = flowOf("one", "two").testIn(this)
assertEquals("one", turbine.expectItem())
assertEquals("two", turbine.expectItem())
turbine.awaitComplete()
Content copied to clipboard
Unlike test which automatically cancels the flow at the end of the lambda, the returned ReceiveTurbine must either consume a terminal event (complete or error) or be explicitly canceled.
Parameters
timeout
If non-null, overrides the current Turbine timeout for this Turbine. See also: withTurbineTimeout.