class Sup {
public void someMethod(){
// do something
}
}
class Sub extends Sup {
public void method(Object obj) {
if (obj == null) {
super.someMethod();
return;
}
// do something
}
}
class SubTest {
@Test
public void testMethodArgIsNull() {
Sub s = new Sub();
Sub spyS = spy(s);
spyS.method(null);
//test case fails
verify(spyS).someMethod();
}
}
if I redefine the method "method" in Sub like, instead of calling super.someMethod(), if i call someMethod(), the test case passed. But I don't want to make any changes in code. help me to test the code..