I found my method using ReflectionUtils
Method myMethod=ReflectionUtils.findMethod(myMockClass.getClass(), "myMethod", myArg.class)
Now I would like to drive this method to return a specified value. Normally, if myMethod
would be public I would write for instance
given(myMockClass.myMethod(myArg)).willReturn(5)
But is there any possibility to do it with private myMethod?
When I've called
given(myMethod.invoke(myClass, myArg)).willReturn(5)
I've got java.lang.reflect.InvocationTargetException. I've read about PowerMock, but I would like to know whether it's possible with Mockito only
Edit:
public int A(args){
int retValue;
... some code here, the most important part
retValue=..
if(some case)
retValue= myMethod(args);
return retValue;
}