Skip to content

Instantly share code, notes, and snippets.

@Foxpace
Last active July 3, 2023 20:46
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 Foxpace/a8da0dfe814d40b90d2b89fdc196edb7 to your computer and use it in GitHub Desktop.
Save Foxpace/a8da0dfe814d40b90d2b89fdc196edb7 to your computer and use it in GitHub Desktop.
Fix for the missing main thread in unit test
@Before
fun setUp() {
// setting up test dispatcher as main dispatcher for coroutines
Dispatchers.setMain(StandardTestDispatcher())
}
@After
fun tearDown() {
// removing the test dispatcher
Dispatchers.resetMain()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment