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

Paul Woitaschek

05/03/2019, 9:01 AM
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

Jonas Bark

05/03/2019, 10:08 AM
are you actually advancing the time in your TestCoroutineDispatcher using advanceTimeBy?
2 Views