Java – why does thencallrealmethod () lose its parameters here?
I have the following code:
when(mockedOperation.getResult(anyDouble(),anyDouble())).thenCallRealMethod(); when(mockedOperation.division(anyDouble(),not(eq(0d)))).thenCallRealMethod();
The operation is similar to the command mode - it encapsulates some specific operations, in this case a simplified division operation Result retrieval does not occur directly, but through contract methods, such as getResult (arg1, arg2) So I called
mockedOperation.division(10d,3d);
But (I debug information from the Operation I actually implemented) I can see that division () is not 10 and 3, but (0,0).
As far as I know, these parameters are lost between thenCallRealMethod () and getResult (), and then call real division ().
What are the reasons for this behavior? If I really need it, how can I properly implement the partial simulation?
UPD. Maybe I should try to say it in another way. For example, how do you create a simulation method of callrealmethod so that the parameters are correctly passed to the endpoint?
Solution
OK, the problem is solved now It turns out that I just encountered another unrecorded function / error in mockito (or I just couldn't find the function of the document) The problem is that in my @ before, I also laugh at this very operation, and when it seems that when one redefines the simulation, some dark magic will happen, and the result is as I have described - the parameters have been lost to some extent