In most cases, this worked in my project:
@Rule public PowerMockRule rule = new PowerMockRule(); static { PowerMockAgent.initializeIfNeeded(); }
Delete / Comment @RunWith(PowerMockRunner.class) and enable the following imports after adding powermock-module-javaagent-1.6.5.jar to your classpath:
import org.junit.Rule; import org.powermock.modules.junit4.rule.PowerMockRule; import org.powermock.modules.agent.PowerMockAgent;
Now right-click-> Coverage As-> Coverage Configurations and add the following lines to the Arguments:
-ea -noverify -javaagent:path/to/powermock-module-javaagent-1.6.5.jar
Click "Apply-> Coverage."
Also note that @Before will not work in this case, so you need to add all the materials in the methods marked with @Test with the method marked with @Before .
being_ethereal Jun 15 '16 at 7:29 2016-06-15 07:29
source share