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

tseisel

02/11/2019, 4:40 PM
What is the recommanded way to test suspending functions that are members of a class ? In the code below my test function is suspended indefinitely and the
assertThat
statement is never reached. Why ?
d

dewildte

02/11/2019, 6:09 PM
Does it make a difference if you return the deferred from
getFoo()
?
t

tseisel

02/11/2019, 7:35 PM
I added some detail to the code after some investigation with the debugger. My class under test is a coroutine-confined cache for the last received
Foo
from a
Flowable
. It seems that the
assertThat
statement is executed. But
runBlocking
prevents the test from finishing.
d

dewildte

02/11/2019, 10:22 PM
I generally avoid
runblocking{}
2 Views