Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JaCoCo code coverage #3

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@

<cobertura.version>2.7</cobertura.version>

<jacoco.version>0.7.5.201505241946</jacoco.version>
<jacoco.path>${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar</jacoco.path>
<jacoco.utReport>${project.build.directory}/jacoco.exec</jacoco.utReport>
<jacoco.utAgentConfig>-javaagent:${jacoco.path}=destfile=${jacoco.utReport}</jacoco.utAgentConfig>
<jacoco-listeners.version>3.5</jacoco-listeners.version>

</properties>

<dependencyManagement>
Expand Down Expand Up @@ -271,6 +277,20 @@
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
</dependency>

<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>${jacoco.version}</version>
<classifier>runtime</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.java</groupId>
<artifactId>sonar-jacoco-listeners</artifactId>
<version>${jacoco-listeners.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<!-- Maven plugin versions are mentioned in order to guarantee the build reproducibility in the long term -->
Expand Down Expand Up @@ -305,9 +325,23 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.13</version>
<configuration>
<!-- JDK 7 - relax bytecode verifier to prevent double -->
<!-- instrumentation issues with OpenJPA tests and JaCoCo -->
<!-- <argLine>-XX:-UseSplitVerifier ${jacoco.utAgentConfig}</argLine> -->
<!-- JDK 8 - bytecode verifier cannot be relaxed or disabled -->
<!-- to prevent runtime errors, OpenJPA tests are ignored -->
<argLine>${jacoco.utAgentConfig}</argLine>
<includes>
<include>**/*Tests.java</include>
</includes>
<properties>
<!-- add SonarQube's JaCoCo listener to enable -->
<!-- gathering of code coverage metrics per test -->
<property>
<name>listener</name>
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
</configuration>
</plugin>
<plugin>
Expand Down
13 changes: 11 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ sonar.projectName=Simple Java project analyzed with the SonarQube Runner
sonar.projectVersion=1.0

# Comma-separated paths to directories with sources (required)
sonar.sources=src
sonar.sources=src/main/java

# Language
sonar.language=java

# Comma-separated paths to directories with tests
sonar.tests=src/test/java

# Comma-separated paths to directories containing the compiled bytecode files corresponding to your source files
sonar.java.binaries=target/classes

# Tells SonarQube where the unit tests code coverage report is
sonar.jacoco.reportPath=target/jacoco.exec

# Encoding of the source files
sonar.sourceEncoding=UTF-8
sonar.sourceEncoding=UTF-8