, , "" - PowerMock; .
IgnoreCall ; ignoreMethodCall() no-op.
: , void. , .
, :
void . , , .
: PowerMock "" - ; "" ! , PowerMock , , void "".
, , . when() Mockito . , : , .
; [mcve] , :
package ghostcat.test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
class IgnoreCall {
public static void ignoreMethodCall(Object o) {
System.out.println("SHOULD NOT SHOW UP: " + o);
}
}
class CuT {
public static Object call(Object bean) {
System.out.println("statement1");
IgnoreCall.ignoreMethodCall(bean);
System.out.println("statement2");
return "whatever";
}
}
@RunWith(PowerMockRunner.class)
@PrepareForTest(IgnoreCall.class)
public class PMTest {
@Test
public void test() {
PowerMockito.mockStatic(IgnoreCall.class);
CuT.call("yeha");
}
}
... IgnoreCall; , "".
:
statement1
statement2
:
statement1
SHOULD NOT SHOW UP: yeha
statement2
, , , .
eclipse neon, IBM java8 JDK JAR powermock-mockito-junit-1.6.6.zip .