SonarQube - FTSRG/cheat-sheets GitHub Wiki
<properties>
<!-- One common coverage report for all submodules -->
<sonar.jacoco.reportPath>${basedir}/../jacoco.exec</sonar.jacoco.reportPath>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<configuration>
<!-- This is the unit test report file that SonarQube will pick up -->
<destFile>${sonar.jacoco.reportPath}</destFile>
<!-- Merge coverage report of submodules -->
<append>true</append>
</configuration>
<executions>
<!-- Measure coverage with JaCoCo -->
<execution>
<id>agent-for-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
- Download JaCoCo, uncompress
lib/jacocoagent.jar
and specify it as thejavaagent
JVM argument to the AUT (Details) - Use RCPTT >= 2.1.0 (Details)
RCPTT test project POM:
<pluginRepositories>
<pluginRepository>
<id>rcptt-snapshots</id>
<name>RCPTT Maven repository</name>
<url>https://repo.eclipse.org/content/repositories/rcptt-snapshots/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.rcptt</groupId>
<artifactId>rcptt-maven-plugin</artifactId>
<version>2.1.0-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
<aut>
<vmArgs>
<vmArg>-javaagent:/tmp/jacocoagent.jar=destfile=../../../jacoco-it.exec</vmArg> <!-- Specify file in parent directory -->
</vmArgs>
</aut>
</configuration>
</plugin>
</plugins>
</build>
- Specify
sonar.jacoco.itReportPath
in the parent POM so that the scope of the coverage is the whole project (Details)
Parent POM:
<properties>
<sonar.jacoco.itReportPath>${basedir}/../jacoco-it.exec</sonar.jacoco.itReportPath> <!-- Points to destfile argument of jacocoagent -->
</properties>