Created
April 12, 2019 00:29
-
-
Save CDRussell/ba7a0a9be3f191641a9a7694f9086ed2 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 ExampleViewModel(private val logger: Logger) : ViewModel() { | |
fun handleError() { | |
viewModelScope.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
class ExampleViewModelTest { | |
private val logger: Logger = mock() | |
private val testee: ExampleViewModel = ExampleViewModel(logger) | |
@Test | |
fun test() = runBlocking { | |
testee.handleError() | |
verify(logger).logErrorEvent() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test fails