Because if it's like this, if for instance I have a CoroutineDispatcher injected that is the IO and the CoroutineScope tha tis the
MainScope()
and I use it like :
@Inject constructor(
...
...
private val mainScope : CoroutineScope,
private val ioDispatcher: CoroutineDispatcher,
...
...
)
And then using it like this
mainScope.launch{
...
result withContext(ioDispatcher) {...}
...
}
If I do
Dispatchers.setMain(TestCoroutineDispatcher())
does it change also the
ioDispatcher
?
On my test I'm doing it like this :
private val testDispatcher = TestCoroutineDispatcher()
private val mainScope = TestCoroutineScope(testDispatcher)
And then on the
@Before
I'm using this
Dispatchers.setMain(testDispatcher)
And on every test I'm using
mainScope.runBlockingTest{...}
or
testDispatcher.runBlockingTest{...}
Is something I could improve?