Skip to content

Instantly share code, notes, and snippets.

@verno3632
Created September 6, 2018 23:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save verno3632/5f9c8fc318bef2db59247bdf1d633cb1 to your computer and use it in GitHub Desktop.
Save verno3632/5f9c8fc318bef2db59247bdf1d633cb1 to your computer and use it in GitHub Desktop.
Extension to test with LiveData in JUnit5
class InstantTaskExecutorExtension : BeforeAllCallback {
override fun beforeAll(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
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment