I’m trying to understand how that rule works, particularly
this.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?