When you are writing test cases, there might be a case that you want to mock only a selected method and other methods of the class should run the real implementation. This is specially useful when the method you are testing calls another methods in the same class.You can use following way to achieve that task.
Class A{
methodA();
methodB();
methodC();
}
We need to test methodA() and it calls methodB() inside. We need to mock methodB().
ClassATest extends TestCase{
testMethodA()
{
A a = new A();
spy = Mockito.spy(a);
Mockito.doReturn(
}
}
0 Comments