I am writing a JUnit test case for methods similar to the examples below:
Class SampleA{ public static void methodA(){ boolean isSuccessful = methodB(); if(isSuccessful){ SampleB.methodC(); } } public static boolean methodB(){
In the test class, I wrote the following test case:
@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 check if the static method C () of the Sample B class is called or not. How can I achieve the use of PowerMockito 1.6? I have tried many things, but it seems to me that this does not work. Any help is appreciated.
junit4 mockito powermock powermockito
Prerak tiwari
source share