I have the following code:
when(mockedOperation.getResult(anyDouble(), anyDouble())).thenCallRealMethod(); when(mockedOperation.division(anyDouble(), not(eq(0d)))).thenCallRealMethod();
Where Operation is something like a Command pattern - it encapsulates some specific action, in this case a simplified one - division. The search result does not occur directly, but using the contract method, for example, getResult(arg1, arg2) . So I call
mockedOperation.division(10d, 3d);
But (from the debugging information in my specific implementation of Operation ), I see that division() gets not 10 and 3 , but (0, 0) .
As far as I understand, these arguments are lost somewhere between thenCallRealMethod() and getResult() and after that they call real division() .
What is the reason for this behavior and how should I correctly execute partial layouts, if I really need it?
UPD. Maybe I should try to say it differently, for example, just how do you create mocks that callRealMethod so that the arguments are correctly delivered to the endpoint?
java mockito mocking
tkroman
source share