I have a map liveData in view model.
val isOpen: LiveData<Boolean> = Transformations.map(shouldTry) {
println("in map")
close()
false
}
fun open() {
println("open called")
}
how can use @spy for open called or not?
@Test
fun test() :runBlockingTest{
viewModel = spy(ViewModel())
// Action
viewModel.shouldTry.value = true
// Expected
verify(viewModel).open()
}
Aucun commentaire:
Enregistrer un commentaire