https://kotlinlang.org logo
#android
Title
# android
d

Daniel Rodak

08/02/2019, 6:40 AM
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

rcd27

08/03/2019, 6:02 AM
You could also try mocking Function1 interface, whis is (T)->A in kotlin syntax.
d

Daniel Rodak

08/03/2019, 9:22 AM
Thanks, but when I mocked it it was still complaining that there is a difference(exactly that Function1 was expected but actual was different)
2 Views