问题
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()
}
来源:https://stackoverflow.com/questions/64444828/spy-mockito-for-map-or-switchmap-livedata