Created
September 6, 2018 23:10
-
-
Save verno3632/5f9c8fc318bef2db59247bdf1d633cb1 to your computer and use it in GitHub Desktop.
Extension to test with LiveData in JUnit5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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