Last active
April 11, 2021 20:57
-
-
Save lisamariewatkins/6aa2c1a2a48b65cd414f7aa31cc3c260 to your computer and use it in GitHub Desktop.
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 : 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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This magic script made my tests work! Thanks!