https://kotlinlang.org logo
#coroutines
Title
# coroutines
c

curioustechizen

09/11/2019, 3:41 PM
This might have been asked before but I could not find much info: Are there any testing utilities for testing Flows? I want to do things like assert the "initial" value of a Flow, perform some action and then assert that the flow emitted another value
d

Dominaezzz

09/11/2019, 3:55 PM
You can use
produceIn
to achieve this. Get the channel and receive items imperatively.
l

louiscad

09/11/2019, 4:43 PM
Also, don't forget to close the channel using
consume { … }
or
cancel()
. I spent quite some time wondering why they would deadlock, and it was because the channel producer would be kept alive, preventing the coroutine scope from completing.
✔️ 2
c

curioustechizen

09/12/2019, 7:09 AM
That worked like a charm. Thanks!