For most dispatchers (Main, IO, Default) it's pret...
# coroutines
j
For most dispatchers (Main, IO, Default) it's pretty straightforward to tell on which thread they will dispatch, but I can't find much about on which thread a StandardTestDispatcher is dispatched. If I call
testDispatcher.scheduler.runCurrent()
, on which thread are the tasks run?
d
runCurrent()
will itself run them.
j
Aah, as in it doesn't switch threads, it will stay on the calling thread
d
Basically, yes.
runCurrent
executes the pending tasks for
StandardTestDispatcher
inline, it doesn't ask any other thread to do it.
j
Thanks for clarifying
d
Also, using
runCurrent
is not recommended: https://github.com/Kotlin/kotlinx.coroutines/issues/3919
Without
runCurrent
,
runTest
will execute the pending tasks, so the main test thread runs them.