I'm getting this error while running junit test in...
# coroutines
s
I'm getting this error while running junit test in android module
Exception in thread "main" java.lang.IllegalStateException: Module with the Main dispatcher had failed to initialize. For tests Dispatchers.setMain from kotlinx-coroutines-test module can be used
Does anyone know
Dispatchers.setMain
with what parameter should be called?
a
Did you import an appropriate dependency to set your main dispatcher?
See https://github.com/Kotlin/kotlinx.coroutines/blob/master/ui/coroutines-guide-ui.md Otherwise you need the test dependency to set your own main dispatcher
s
the one mentioned in the message of exception? yes#
I just don't know what to pass into setMain
a
Are you not using android, swing, or javafx? Do you actually need a main dispatcher?
s
yes. android. It is working on main source set. It is throwing this in junit test
Thank you but I'm still getting the same exception
a
Can you post your unit test?
s
it is in the channel