I have a wrapper class for CoroutineDispatcher tha...
# coroutines
e
I have a wrapper class for CoroutineDispatcher that I use so that for tests I can provide test dispatchers:
Copy code
interface MyDispatchers {
  val main: CoroutineDispatcher
  val io: CoroutineDispatcher
  val computation: CoroutineDispatcher
  val unconfined: CoroutineDispatcher
}
Instead of using
Dispatchers.*
I use one of the properties from `MyDispatchers`(which are set to the corresponding
Dispatchers.*
) Is this necessary, or does the coroutines test artifact have a construct that allows you to use
Dispatchers.*
and control them during a test?
­čĹî 2
e
the others can't - I'm not sure it ever makes sense to change Dispatchers.Unconfined, as it has some unique behavior
e
So the correct approach would be to keep what I have, and for tests, set the Dispatchers to a
TestCoroutineDispatcher
(aside from Unconfined because of its behavior)? Or am I better off using
Dispatchers.*
and rely on the behavior of
runBlockingTest
for time advancement, etc... The reason I ask is because it's pretty clunky passing
MyDispatchers
around, but I don't want to not use it, and paint myself into a corner later on if I need a test dispatcher.
e
my team has chosen to use our own Dispatchers singleton object, like the built in one but with IO settable
e
Can you share some examples of the things you do when overriding IO?
e
the only thing we override it to is the test dispatcher
(which is customized to log uncaught exceptions and report them at the end of the test, but anyway)
e
Ok thanks for the help