title: Unable to get Jacoco to work with Powermockito using offline instrumentation
body: <p>Given that Jacoco doesn't play nicely with PowerMockito when instrumenting "on the fly", I've been trying to configure offline instrumentation in the hope this will give me proper unit test coverage for classes that use PowerMockito.</p>
  
  <p>I've setup my pom as below but I still get zero % coverage on my test class. Any help much appreciated as it's driving me slowly bonkers!</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;mandy&lt;/groupId&gt;
      &lt;artifactId&gt;jacoco-test&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;jacoco-test Maven Webapp&lt;/name&gt;
      &lt;url&gt;http://maven.apache.org&lt;/url&gt;
      &lt;properties&gt;
          &lt;powermock.version&gt;1.5.4&lt;/powermock.version&gt;
          &lt;jacoco.version&gt;0.7.1.201405082137&lt;/jacoco.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
              &lt;artifactId&gt;org.jacoco.agent&lt;/artifactId&gt;
              &lt;classifier&gt;runtime&lt;/classifier&gt;
              &lt;version&gt;${jacoco.version}&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.powermock&lt;/groupId&gt;
              &lt;artifactId&gt;powermock-module-junit4&lt;/artifactId&gt;
              &lt;version&gt;${powermock.version}&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.powermock&lt;/groupId&gt;
              &lt;artifactId&gt;powermock-api-mockito&lt;/artifactId&gt;
              &lt;version&gt;${powermock.version}&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.10&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
                  &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;${jacoco.version}&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;instrument&lt;/id&gt;
                          &lt;phase&gt;process-classes&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;instrument&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                      &lt;execution&gt;
                          &lt;id&gt;restore-report&lt;/id&gt;
                          &lt;phase&gt;prepare-package&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;restore-instrumented-classes&lt;/goal&gt;
                              &lt;goal&gt;report&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.17&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;!--&lt;argLine&gt;${argLine}&lt;/argLine&gt;--&gt;
                      &lt;systemPropertyVariables&gt;
                          &lt;!-- JaCoCo runtime must know where to dump coverage: --&gt;
                          &lt;jacoco-agent.destfile&gt;target/jacoco.exec&lt;/jacoco-agent.destfile&gt;
                      &lt;/systemPropertyVariables&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
          &lt;finalName&gt;jacoco-test&lt;/finalName&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>here is my class under test:</p>
  
  <pre><code>public class Utils {
  
      private Utils() {
  
      }
  
      public static String say(String s) {
          return "hello:"+s;
      }
  }
  </code></pre>
  
  <p>here is my test:</p>
  
  <pre><code>@RunWith(PowerMockRunner.class)
  
  @PrepareOnlyThisForTest(Utils.class)
  @PowerMockIgnore("org.jacoco.agent.rt.*")
  public class UtilsTest {
  
      @Test
      public void testSay() throws Exception {
          PowerMockito.mockStatic(Utils.class);
          Mockito.when(Utils.say(Mockito.anyString())).thenReturn("hello:mandy");
          assertEquals("hello:mandy", Utils.say("sid"));
      }
  
  }
  </code></pre>
  
  <p>I run mvn clean install which generates the jacoco.exe</p>
  
  <p>Coverage report (generated from jacoco.exec using an ant script ):-</p>
  
  <p><img src="https://i.stack.imgur.com/bskW1.png" alt="Coverage report"></p>