Skip to content

Instantly share code, notes, and snippets.

@prokash-sarkar
Created February 24, 2021 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prokash-sarkar/4e29d9c54eaed362d840d3c07e7a387b to your computer and use it in GitHub Desktop.
Save prokash-sarkar/4e29d9c54eaed362d840d3c07e7a387b to your computer and use it in GitHub Desktop.
@ExperimentalCoroutinesApi
class MainCoroutineRule : 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()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment