I have a method, which is recursive:
For example,
public static int myMethod(int index, int number) {
if (index<4){
index = index + number;
return myMethod(index, number+1);
}
return index;
}
Now this is just a basic example. When I now want to test, how can I verify with Mockito, how many times the method gets called, because the parameters change?
Verify (myMethod(1,2)).times(3) would not work, because it only gets called once, then 1,2 will change.
This could help but won't verify if the method was invoked with correct arguments:
Mockito.verify(myMethod(Mockito.anyInt(), Mockito.anyInt()), Mockito.times(3));
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