Skip to content

Instantly share code, notes, and snippets.

@hongbeomi
Created July 10, 2022 09:38
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 hongbeomi/cf0fa9172e247bb137f9aa7dc8ee527f to your computer and use it in GitHub Desktop.
Save hongbeomi/cf0fa9172e247bb137f9aa7dc8ee527f to your computer and use it in GitHub Desktop.
class MainDispatcherRule(
val dispatcher = TestCoroutineDispatcher()
) : TestWatcher() {
override fun starting(description: Description?) {
super.starting(description)
Dispatchers.setMain(dispatcher)
}
override fun finished(description: Description?) {
super.finished(description)
Dispatchers.resetMain()
dispatcher.cleanupTestCoroutines()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment