interface Foo {
fun flowValue(): Flow<Value> // flow the stored value
suspend fun setValue(value: Value) // update the stored value
}
however the implementation is not for me to control, and sometimes
flowValue()
sometimes emit the old value several times before emitting the set value. What is the best way to test this?
knthmn
04/07/2021, 3:34 AM
My current solution is just to do
Copy code
setValue(bar)
flowValue().first { it == bar }
but it only deadlocks instead of failing when the implementation is wrong. The implementation contains Java threading too.
l
louiscad
04/07/2021, 7:56 AM
Well, either there's bugs in the interface implementation that wraps what you don't control, or that thing you don't control isn't reliable. Or you might you use wrong API wrapper 🤔
k
knthmn
04/07/2021, 9:54 AM
It is just implemented asynchronously (e.g. a video player). The value I want will eventually come and it is ok since I only care about the most updated status. I just want a better way to test it.