I'm passing function as a parameter, this function...
# android
d
I'm passing function as a parameter, this function comes from dagger injected interface. Works as expected but I'm struggling with adding tests using
Mockito
. When I want to verify that a method with function as parameter was called, it always complains about strange difference. The difference is in the first brackets, it's like contex of the test method. Using
Captors
didn't help, because I mock the injected interface it will return null
To solve this I had to move my function as parameter to the interface which is being mocked(classC)
r
You could also try mocking Function1 interface, whis is (T)->A in kotlin syntax.
d
Thanks, but when I mocked it it was still complaining that there is a difference(exactly that Function1 was expected but actual was different)