What’s the best way to test multiplatform coroutin...
# coroutines
s
What’s the best way to test multiplatform coroutines that have
delay
in them?
a
What do you want to test?
s
I have an class that is responsible for ensuring that the app is still logged in. If we don’t talk to the server every x minutes, then we show a message to the user that they need internet to proceed
The logic amounts to a few coroutines with
delay
talking making network calls and updating state. I’m not sure on the best way to test this.
m
Make sure the tested coroutine runs on TestCoroutineDispatcher. It will auto advance the time and if you want to control it manually you have methods for that too - pauseSth and advanceTimeBy
a
You have to test that you make one network call. Delay… If you work with coroutines you can broke this. If you put too much methods in the same thread you will broke delay. But I don’t know how you can test it.