Skip to content

Instantly share code, notes, and snippets.

@lisamariewatkins
Last active April 11, 2021 20:57
Show Gist options
  • Select an option

  • Save lisamariewatkins/6aa2c1a2a48b65cd414f7aa31cc3c260 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

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