Skip to content

Instantly share code, notes, and snippets.

@hongbeomi
Created July 10, 2022 09:40
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/d975a40baeb2121d2a699688beba83b1 to your computer and use it in GitHub Desktop.
Save hongbeomi/d975a40baeb2121d2a699688beba83b1 to your computer and use it in GitHub Desktop.
class MainDispatcherRule(
val testDispatcher: TestDispatcher = UnconfinedTestDispatcher()
): TestWatcher() {
override fun starting(description: Description) {
super.starting(description)
Dispatchers.setMain(testDispatcher)
}
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