jean
08/24/2020, 6:20 PMthis.coroutineContext[ContinuationInterceptor] as CoroutineDispatcher
class CoroutineTestRule : TestWatcher(), TestCoroutineScope by TestCoroutineScope() {
override fun starting(description: Description?) {
super.starting(description)
Dispatchers.setMain(this.coroutineContext[ContinuationInterceptor] as CoroutineDispatcher)
}
override fun finished(description: Description?) {
super.finished(description)
Dispatchers.resetMain()
}
}
What does it do exactly?
While debugging, I see that this.coroutineContext[ContinuationInterceptor]
returns a TestCoroutineDispatcher
, is that because the rule implement TestCoroutineScope which has a TestCoroutineDispatcher as default dispatcher?octylFractal
08/24/2020, 6:40 PM