I have an espresso test which fails because at the...
# coroutines
p
I have an espresso test which fails because at the start of my fragment, I call
launch(Dispatchers.Main) { ... withTimeoutOrNull(1000) }
When I set that timeout to
0
, the tests passes because the views are ready. Now I thought, that in my tests I can set the main dispatcher for advancing the time automatically (so that the timout is thrown immediately and don't need to adjust the production code for my tests):
Dispatchers.setMain(TestCoroutineDispatcher())
. However that doesn't work. Has someone and idea why and how I can fix it?
j
are you actually advancing the time in your TestCoroutineDispatcher using advanceTimeBy?