I am using mockito 1.9.5 and wanting to test a class that looks something like this
class MyClass {
public MyClass(String arg1, String arg2, String arg3) {
this.arg1 = arg1; this.arg2=arg2;...
}
public executeLogic () {
if (arg1) {// logic to arg3}
else if (arg2) {// logic to arg3 }
}
}
I tried to mock it but when i execute the real executeLogic method, it looks for arg1, arg2 and fails. I have tried to spy but the doReturn method executes the real method and fails.
@Test public void testLogic() {
MyClass mc = Mockito.mock(MyClass.class);
when(mc.executeLogic()).thenCallRealMethod();
}
Any pointers ?
Aucun commentaire:
Enregistrer un commentaire