I'm trying to verify the following method gets called using Mockito:
class Notifier {
def forward(request: ServletRequest)(onFailure: => Unit) : Unit
}
Here's the verification on a mock:
val notifier = mock[Notifier]
there was one(notifier).forward(any[ServletRequest])(any[() => Unit])
And I get the exception:
The mock was not called as expected:
Invalid use of argument matchers!
3 matchers expected, 2 recorded.
This exception may occur if matchers are combined with raw values:
//incorrect:
someMethod(anyObject(), "raw String");
When using matchers, all arguments have to be provided by matchers.
For example:
//correct:
someMethod(anyObject(), eq("String by matcher"));
I know this is caused by the last parameterless function. How can I perform a verify properly here?
Could you try Function0[Unit]
?
there was one(notifier).forward(any[ServletRequest])(any[Function0[Unit]])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With