Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,7 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<!-- 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. -->
<destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<sonar.tests>${project.basedir}/target/test-classes</sonar.tests>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
<artifactId>app</artifactId>

<name>Java :: JaCoco Multi Modules :: App</name>

<properties>
<sonar.tests>${project.basedir}/target/test-classes</sonar.tests>
<sonar.java.binaries>${project.basedir}/target/classes</sonar.java.binaries>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package example;

public class HelloWorld {
public class HelloWorld implements Cloneable {

public void coveredByUnitTest() {
System.out.println("coveredByUnitTest1");
Expand All @@ -16,5 +16,16 @@ public void coveredByIntegrationTest() {
public void notCovered() {
System.out.println("notCovered");
}


public void morenotCovered() {
System.out.println("morenotCovered");
}

public void morenotCovered2() {
System.out.println("morenotCovered");
}

public void morenotCovered3() {
System.out.println("morenotCovered");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,19 @@
<!-- 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. -->
<sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
<jacocoReportDir>${project.basedir}/../target</jacocoReportDir>
<sonar.jacoco.reportPath>${jacocoReportDir}/jacoco.exec</sonar.jacoco.reportPath>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.language>java</sonar.language>
<sonar.host.url>https://sonar.symphony.com</sonar.host.url>
<sonar.analysis.mode>preview</sonar.analysis.mode>
<sonar.github.pullRequest>3</sonar.github.pullRequest>
<sonar.github.repository>marturi/sonar-examples</sonar.github.repository>
<jacoco.destfile>${project.basedir}/../target/jacoco.exec</jacoco.destfile>
<maven.surefire.report.plugin>2.19.1</maven.surefire.report.plugin>
<jacoco.plugin.version>0.7.6.201602180812</jacoco.plugin.version>
<jacoco.excludePattern/>
</properties>

<dependencies>
Expand All @@ -37,65 +48,111 @@
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<forkCount>4</forkCount>
<reuseForks>false</reuseForks>
<argLine>-Xmx2048m ${surefireArgLine}</argLine>
<includes>
<include>**/*Test.java</include>
</includes>
<skip>${skip.surefire.tests}</skip>
</configuration>
</plugin>



<plugin>
<!-- Code Coverage -->
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.plugin.version}</version>
<configuration>
<haltOnFailure>true</haltOnFailure>
<excludes>
<exclude>${jacoco.excludePattern}</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${jacoco.destfile}</destFile>
<append>true</append>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${jacoco.destfile}</dataFile>
<outputDirectory>${jacocoReportDir}</outputDirectory>
<skip>${skip.surefire.tests}</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>


</pluginManagement>



<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>

<plugin>
<!-- for unit test execution -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<!-- For code coverage -->
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven.surefire.report.plugin}</version>
<configuration>
<showSuccess>false</showSuccess>
<alwaysGenerateSurefireReport>true</alwaysGenerateSurefireReport>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.plugin.version}</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<excludes>
<exclude>${jacoco.excludePattern}</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</reporting>

<profiles>
<profile>
<id>sonar-coverage</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<append>true</append>
</configuration>
<executions>
<execution>
<id>agent-for-ut</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>agent-for-it</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sonar.language>java</sonar.language>
<sonar.host.url>https://sonar.symphony.com</sonar.host.url>
<sonar.analysis.mode>preview</sonar.analysis.mode>
<sonar.github.pullRequest>3</sonar.github.pullRequest>
<sonar.github.repository>marturi/sonar-examples</sonar.github.repository>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ public String toto() {
public void uncoveredMethod() {
System.out.println(foo());
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

}

public void uncoveredMethod2() {
System.out.println(foo());
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

}
}