@RunWith(PowerMockRunner.class)
@PrepareForTest(StaticMethodsHolder.class)
public class MockNTestStaticMethodsHolder {
@Rule public PowerMockRule rule = new PowerMockRule();
@Test public void staticSvcClientMethod () {
// blah blah blah
mockstatic (StaticMethodsHolder.class);
expect (StaticMethodsHolder.TomBradyIsStillTheBest()).andReturn(UNQUESTIONABLY);
expect (StaticMethodsHolder.NEPatriotsStillTheBest()).andReturn(MAYBE);
expect (StaticMethodsHolder.NEPatriotsLiiWereIdiots()).andReturn(TOTALLY);
expect (StaticMethodsHolder.NEPatriotsWinsLiii()).andReturn(RU_KIDDING_ME);
}
}
Maven dependencies/properties in the following order:
- powermock-version 1.6.6
- easymock-version 3.4
- easymock
- powermock-module-junit4
- powermock-api-easymock
- powermock-module-junit4-rule-agent (removing this causes constructor issues)
- powermock-module-junit4-rule (removing this dependency has no effect)
- powermock-classloading-xstream
Runtime error:
java.lang.IllegalStateException PowerMockRule can only be used
with the system classloader but was loaded by
org.powermock.core.classloader.MockClassLoader.
PowerMock is biting is own tail. It wants to use its own classloader, but the JVM says PowerMockRule must be loaded by system's.
What can I do to resolve this?