Skip to content

Instantly share code, notes, and snippets.

@cp-radhika-s
Last active December 27, 2021 08:35
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 cp-radhika-s/b8c7cc16fe9eaa51e608406c26462ecd to your computer and use it in GitHub Desktop.
Save cp-radhika-s/b8c7cc16fe9eaa51e608406c26462ecd 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