title: Integration Test Coverage in SonarQube from JaCoCo Maven plug-in showing 0%
body: <p>We have a multi-module multi-language maven java project with coverage analysis with jacoco.
  The main part of the modules is backend (Java code) with a REST API and our webapp module contains the frontend (AngularJS) and the Integration-Tests in java.
  Our Jacoco-IT.exec file contains around 100Kb of data so we guess some Coverage data for the Integration tests could get collected. Nevertheless we cant see any coverage in SonarQube (using Version 5.0 and 4.5)</p>
  
  <p>We run build the Project and run the integration tests with</p>
  
  <pre><code>mvn clean install
  </code></pre>
  
  <p>and analyse the data with</p>
  
  <pre><code>mvn sonar:sonar
  </code></pre>
  
  <p>The Project is configured as multi language, but we just analyse the java code yet (we used to have a monolanguage configuration but there was no difference in the results related to the coverage data)</p>
  
  <p>Our parent POM:</p>
  
  <pre><code>&lt;properties&gt;
      &lt;hibernate.version&gt;4.2.2.Final&lt;/hibernate.version&gt;
      &lt;spring.version&gt;3.2.3.RELEASE&lt;/spring.version&gt;
      &lt;resteasy.version&gt;3.0.4.Final&lt;/resteasy.version&gt;
      &lt;cucumber.version&gt;1.1.3&lt;/cucumber.version&gt;
      &lt;selenium-java.version&gt;2.33.0&lt;/selenium-java.version&gt;
      &lt;!-- Sonar --&gt;
      &lt;sonar.java.coveragePlugin&gt;jacoco&lt;/sonar.java.coveragePlugin&gt;
      &lt;sonar.dynamicAnalysis&gt;reuseReports&lt;/sonar.dynamicAnalysis&gt;
      &lt;sonar.jacoco.itReportPath&gt;${project.basedir}/../target/jacoco-it.exec&lt;/sonar.jacoco.itReportPath&gt;
      &lt;jacoco.dataFile&gt;${project.basedir}/../target/jacoco-it.exec&lt;/jacoco.dataFile&gt;
  &lt;/properties&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;configuration&gt;
                  &lt;source&gt;1.7&lt;/source&gt;
                  &lt;target&gt;1.7&lt;/target&gt;
                  &lt;debug&gt;true&lt;/debug&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;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;default-prepare-agent&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;prepare-agent&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;default-prepare-agent-integration&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;prepare-agent-integration&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;default-report&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;report&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;default-report-integration&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;report-integration&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.16&lt;/version&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
      &lt;pluginManagement&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.7.2.201409121644&lt;/version&gt;
              &lt;/plugin&gt;
      &lt;/pluginMangement&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>Our POM from the webapp with the Integration Tests:</p>
  
  <pre><code>&lt;properties&gt;
      &lt;sonar.sources&gt;src/main&lt;/sonar.sources&gt;
  &lt;/properties&gt;
  &lt;build&gt;
      &lt;finalName&gt;web&lt;/finalName&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
          &lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;
          &lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;8.1.7.v20120910&lt;/version&gt;
          &lt;configuration&gt;...&lt;/configuration&gt;
          &lt;executions&gt;...&lt;/executions&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;configuration&gt;
                  &lt;!-- The destination file for the code coverage report has to be set to the same value
                  in the parent pom and in each module pom. Then JaCoCo will add up information in
                  the same report, so that, it will give the cross-module code coverage. --&gt;
                  &lt;destFile&gt;${project.basedir}/../target/jacoco-it.exec&lt;/destFile&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.16&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;default&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;integration-test&lt;/goal&gt;
                          &lt;goal&gt;verify&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>As you can see in our parent POM we configured the itReportPath to be in the same directory for all Modules. So when Sonar analyses all modules it reads always the same coverage data and should align them with the debug information from the binaries of the current module. 
  During the analyse phase of maven (mvn sonar:sonar) we get some messages where we are not sure if they are a problem:</p>
  
  <p>for all java modules we get the folloing lines:</p>
  
  <pre><code>    [INFO] [17:30:42.992] Sensor SurefireSensor...
      [INFO] [17:30:42.992] parsing \git\airport-core\rest\target\surefire-reports
      [INFO] [17:30:43.009] Sensor SurefireSensor done: 17 ms
      [INFO] [17:30:43.009] Sensor JaCoCoItSensor...
      [INFO] [17:30:43.010] Analysing \git\airport-core\rest\..\target\jacoco-it.exec
      [INFO] [17:30:43.018] No information about coverage per test.
      [INFO] [17:30:43.018] Sensor JaCoCoItSensor done: 9 ms
      [INFO] [17:30:43.018] Sensor JaCoCoOverallSensor...
      [INFO] [17:30:43.027] Analysing \git\airport-core\rest\target\sonar\jacoco-overall.exec
      [INFO] [17:30:43.046] No information about coverage per test.
      [INFO] [17:30:43.046] Sensor JaCoCoOverallSensor done: 28 ms
  </code></pre>
  
  <p>Is "No information about coverage per test." a Problem? Ok, we dont know which test caused the coverage, but we should get a different value in SonarQube than 0%</p>
  
  <p>and for our webapp module, which does not contain any java sources/classes except for the integration test sources itself, we get the following lines:</p>
  
  <pre><code>    [INFO] [17:30:48.370] Sensor JaCoCoItSensor...
      [INFO] [17:30:48.370] No JaCoCo analysis of project coverage can be done since there is no class files.
      [INFO] [17:30:48.370] Sensor JaCoCoItSensor done: 0 ms
  </code></pre>
  
  <p>This shouldn't be a problem, as there are no classes in this module.
  Is this observation correct?</p>
  
  <p>To the Main part our configruation bases on the official SonarCube demo configuration (<a href="https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/java/code-coverage/combined%20ut-it/combined-ut-it-multimodule-maven-jacoco">https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/java/code-coverage/combined%20ut-it/combined-ut-it-multimodule-maven-jacoco</a>), we just added the "prepare-agent-integration" goal. And of course changed it to a multi-language Project.</p>
  
  <p>We found a lot of depricated information on the web (argLine settings and so on) which didn't change anything for us.</p>
  
  <p>Links to the Documentation and Tutorials we used:</p>
  
  <ul>
  <li><a href="http://docs.sonarqube.org/display/SONAR/Code+Coverage+by+Integration+Tests+for+Java+Project">http://docs.sonarqube.org/display/SONAR/Code+Coverage+by+Integration+Tests+for+Java+Project</a></li>
  <li><a href="http://www.sonarqube.org/measure-coverage-by-integration-tests-with-sonar-updated/">http://www.sonarqube.org/measure-coverage-by-integration-tests-with-sonar-updated/</a></li>
  </ul>