Shoaib khalid
11/10/2023, 9:26 PMManish malviya
11/11/2023, 7:08 AMShoaib khalid
11/11/2023, 7:09 AM`when`(favoriteRepo.addFlutterFavorite(any(), any())).thenAnswer {
val callback = it.arguments[1] as (Long) -> Unit
callback(100L)
}
favoriteRepo.addFlutterFavorite(null) { result ->
assert(result == 100L)
}
The above testcase passed means the callback value is 100 which i gave in thenAnswer block for addFlutterFavorite()
but the problem is if an other method calls addFlutterFavoite()
then the it's callback never executes in my actual code but in above test case the callback works fine.
@Manish malviya can you please identify any mistake or any suggestion? thanksval argumentCaptor = argumentCaptor<(Long) -> Unit>()
`when`(favoriteRepo.addFlutterFavorite(Mockito.any(), argumentCaptor.capture())).thenAnswer {
argumentCaptor.firstValue.invoke(100L)
}
Manish malviya
11/11/2023, 7:46 AM