Created
April 12, 2019 00:02
-
-
Save CDRussell/527e44d83e3c508ffd422dadbb801981 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 ErrorHandler(private val logger: Logger) { | |
fun handleError() { | |
GlobalScope.launch(Dispatchers.IO) { | |
heavyOperation() | |
logger.logErrorEvent() | |
} | |
} |
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
@Test | |
fun test() = runBlocking<Unit> { | |
val testee = ErrorHandler(logger) | |
testee.handleError() | |
verify(logger).logErrorEvent() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of a failing unit test.
This test will fail because the unit test will complete before the coroutine will have had a change to launch and execute.