I am writing JUnit test case for methods similar to sample given below:
Class SampleA{
public static void methodA(){
boolean isSuccessful = methodB();
if(isSuccessful){
SampleB.methodC();
}
}
public static boolean methodB(){
//some logic
return true;
}
}
Class SampleB{
public static void methodC(){
return;
}
}
I wrote the following test case in my test class:
@Test
public void testMethodA_1(){
PowerMockito.mockStatic(SampleA.class,SampleB.class);
PowerMockito.when(SampleA.methodB()).thenReturn(true);
PowerMockito.doNothing().when(SampleB.class,"methodC");
PowerMockito.doCallRealMethod().when(SampleA.class,"methodA");
SampleA.methodA();
}
Now I want to verify whether static methodC() of class Sample B is called or not. How can I achieve using PowerMockito 1.6? I have tried many things but it doesn't seems to be working out for me. Any help is appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…