Open ekizy opened 5 years ago
You're trying to verify that getTopHeadlines(...)
is passed two function references, but the implementation of getTopHeadlines
expects two lambda. AFAIK lambdas and function references are two different things. Have you considered using a Matcher
in your verification instead?
Like this:
verify(topHeadlinesRepository, times(1)).getTopHeadlines(any(), any(), any())
Fun fact: Function references are actually an example of reflection. This is why the object returned by this type of operation also contains information about the referred function. You can actually do the following with them:
fun isOdd(i: Int) = i % 2 == 1
val annotations = ::isOdd.annotations
val parameters = ::isOdd.parameters
println(annotations.size) // Prints: 0
println(parameters.size) // Prints: 1
Hi, I have function which has 3 parameters and 2 of these parameters are functions. However when i try to verify a function i get this error.
Here is my function's declaration
And here is my test function
@Test fun testLoadInitial_success() { whenever(topHeadlinesRepository.getTopHeadlines(requestModel, ::handleSuccess, ::handleFailure)).then { handleSuccess(articleContainerModel) }