I'm using Mockito 3.1.0.
I'm trying to Mock my method with this syntax:
when(mockedObject.myMethod(any(HttpServletRequest.class)).thenReturn(1);
myMethod
is simply:
public Integer myMethod(HttpServletRequest request) {
return 0;
}
In the method I'm testing it's simply called by:
int r = myObject.myMethod(request);
But I'm getting:
org.mockito.exceptions.misusing.PotentialStubbingProblem:
Strict stubbing argument mismatch. Please check:
- this invocation of 'myMethod' method:
mockedObject.myMethod(null);
-> at somefile.java:160)
- has following stubbing(s) with different arguments:
1. mockedObject.myMethod(null);
-> at somefileTest.java:68)