Skip to content

Instantly share code, notes, and snippets.

@lisamariewatkins
Last active April 11, 2021 20:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lisamariewatkins/6aa2c1a2a48b65cd414f7aa31cc3c260 to your computer and use it in GitHub Desktop.
Save lisamariewatkins/6aa2c1a2a48b65cd414f7aa31cc3c260 to your computer and use it in GitHub Desktop.
class InstantTaskExecutorExtension : BeforeEachCallback, AfterEachCallback {
override fun beforeEach(context: ExtensionContext?) {
ArchTaskExecutor.getInstance()
.setDelegate(object : TaskExecutor() {
override fun executeOnDiskIO(runnable: Runnable) = runnable.run()
override fun postToMainThread(runnable: Runnable) = runnable.run()
override fun isMainThread(): Boolean = true
})
}
override fun afterEach(context: ExtensionContext?) {
ArchTaskExecutor.getInstance().setDelegate(null)
}
}
@nicoqueijo
Copy link

This magic script made my tests work! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment