title: Jacoco + Surefire Maven plugins always show 0% coverage
body: <p>I got a multi-module maven project on which i want to generate a jacoco report with the unit coverage. Currently i am using arqullian surefire and jacoco maven plugins, which both are defined in only one module. The tests run on a JBoss EAP 7.2</p>
  
  <p>Although the jacoco report is generated, i always get a 0% coverage on all my test classes which are deployed as an archive <strong>org.jboss.shrinkwrap.api.spec.WebArchive</strong> on my JBoss server even though there are several methods covered by the Unit tests.<br>
  <strong>Important</strong>: Other unit tests performed without a deployment, do show some coverage on the report</p>
  
  <p><a href="https://i.stack.imgur.com/1gcWh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1gcWh.png" alt="enter image description here"></a></p>
  
  <p>Below is my maven configuration</p>
  
  <pre><code>&lt;plugins&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.22.2&lt;/version&gt;
        &lt;configuration&gt;
           &lt;skip&gt;${skipTests}&lt;/skip&gt;
           &lt;argLine&gt;${surefireArgLine}&lt;/argLine&gt;
        &lt;/configuration&gt;
     &lt;/plugin&gt;
     &lt;plugin&gt;
        &lt;artifactId&gt;maven-surefire-report-plugin&lt;/artifactId&gt;
        &lt;version&gt;2.22.2&lt;/version&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;0.8.5&lt;/version&gt;
        &lt;executions&gt;
           &lt;execution&gt;
              &lt;id&gt;pre-unit-test&lt;/id&gt;
              &lt;goals&gt;
                 &lt;goal&gt;prepare-agent&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                 &lt;destFile&gt;${project.build.directory}/coverage-reports/jacoco-ut.exec&lt;/destFile&gt;
                 &lt;propertyName&gt;surefireArgLine&lt;/propertyName&gt;
              &lt;/configuration&gt;
           &lt;/execution&gt;
           &lt;execution&gt;
              &lt;id&gt;post-unit-test&lt;/id&gt;
              &lt;phase&gt;test&lt;/phase&gt;
              &lt;goals&gt;
                 &lt;goal&gt;report&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                 &lt;dataFile&gt;${project.build.directory}/coverage-reports/jacoco-ut.exec&lt;/dataFile&gt;
                 &lt;outputDirectory&gt;${project.reporting.outputDirectory}/jacoco-ut&lt;/outputDirectory&gt;
              &lt;/configuration&gt;
           &lt;/execution&gt;
        &lt;/executions&gt;
     &lt;/plugin&gt;
  &lt;/plugins&gt;
  </code></pre>
  
  <p>Below my dependencies used:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.dbunit&lt;/groupId&gt;
      &lt;artifactId&gt;dbunit&lt;/artifactId&gt;
      &lt;version&gt;2.7.0&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.jboss.shrinkwrap.resolver&lt;/groupId&gt;
      &lt;artifactId&gt;shrinkwrap-resolver-api-maven&lt;/artifactId&gt;
      &lt;version&gt;3.1.4&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.jboss.shrinkwrap.resolver&lt;/groupId&gt;
      &lt;artifactId&gt;shrinkwrap-resolver-impl-maven&lt;/artifactId&gt;
      &lt;version&gt;3.1.4&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.jboss.shrinkwrap.resolver&lt;/groupId&gt;
      &lt;artifactId&gt;shrinkwrap-resolver-spi&lt;/artifactId&gt;
      &lt;version&gt;3.1.4&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.jboss.arquillian.junit&lt;/groupId&gt;
      &lt;artifactId&gt;arquillian-junit-core&lt;/artifactId&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.jboss.arquillian.junit&lt;/groupId&gt;
      &lt;artifactId&gt;arquillian-junit-container&lt;/artifactId&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.jboss.arquillian.protocol&lt;/groupId&gt;
      &lt;artifactId&gt;arquillian-protocol-servlet&lt;/artifactId&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
      &lt;artifactId&gt;org.jacoco.core&lt;/artifactId&gt;
      &lt;version&gt;0.8.5&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Arqulian XML </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.org/schema/arquillian         http://jboss.org/schema/arquillian/arquillian_1_0.xsd"&gt;
     &lt;!-- Force the use of the Servlet 3.0 protocol with all containers, as it is the most mature --&gt;
     &lt;defaultProtocol type="Servlet 3.0" /&gt;
     &lt;!-- Example configuration for a remote JBoss EAP 7 instance --&gt;
     &lt;container qualifier="jboss" default="true"&gt;
        &lt;!-- If you want to use the JBOSS_HOME environment variable, just delete the jbossHome property --&gt;
        &lt;configuration&gt;
           &lt;!--   &lt;property name="javaVmArguments"&gt;${jacoco.agent}&lt;/property&gt;  --&gt;
        &lt;/configuration&gt;
     &lt;/container&gt;
  &lt;/arquillian&gt;
  </code></pre>
  
  <p>On one of my configurations (not the above), i remember seeing a warning that the ${jacoco.agent} was not used.  So i did comment it out again. </p>
  
  <p>When running the mvn clean install goal, in my console logs i see following variables set to the <strong>surefireArgLine</strong> </p>
  
  <pre><code>[INFO] --- jacoco-maven-plugin:0.8.5:prepare-agent (pre-unit-test) @ alis-ejb ---
  [INFO] surefireArgLine set to -javaagent:C:\\Users\\user\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.5\\org.jacoco.agent-0.8.5-runtime.jar=destfile=c:\\Projects\\Projectname\\ejb-module\\target\\coverage-reports\\jacoco-ut.exec
  </code></pre>
  
  <p>All my tests are executed normaly and i am able to generate a surefire report command with surefire-report that lists all the unit test executions. I am thinking if am missing a mvn goal for jacoco that calculates the coverage, but it looks that i am still missing something</p>
  
  <p><strong>Update 1</strong>: I start to believe that the issue is created due to the usage of Arquilian, and i should use the pre-integration-test phases instead. But not sure yet.</p>
  
  <p><strong>Update 2</strong>: I just noticed that for one of my Unit tests i see some coverage. The difference between this unit test and the rest is the one Class containing the tests of which a coverage as shown, are simple Unit tests, whereas for the rest of my Test classes on which i do not get a coverage report from Jacoco a <em>org.jboss.shrinkwrap.api.spec.WebArchive</em> deployment is created. Some more details on this. 90% of my tests, are of this structure. A webarchive is created and deployed on JBoss EAP 7.  </p>