static method mocking example
import static org.powermock.api.mockito.PowerMockito.doReturn; import static org.powermock.api.mockito.PowerMockito.mockStatic; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) @PrepareForTest(ZStatic.class) public class ZStaticTest { @Test public void sayHello() throws Exception { mockStatic(ZStatic.class); doReturn("안녕하세요").when(ZStatic.class, "hello"); System.out.println(ZStatic.hello()); } }