Created
March 21, 2019 08:11
-
-
Save manuelvicnt/751f4b77e91b7be2bc5f7981b25ee75e to your computer and use it in GitHub Desktop.
Testing viewModelScope
This file contains hidden or 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 MyViewModel(dependency: ExternalDependency) : ViewModel() { | |
fun run() { | |
viewModelScope.launch { | |
dependency.doStuff() | |
} | |
} | |
} | |
class MyViewModelTest { | |
private var dependency = mock() | |
// Init mocks | |
@Test | |
fun testVM() = runBlocking { | |
val vm = ViewModel() | |
verify(dependency).doStuff() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment