ARTEMIS-1265 JaCoCo profile for getting code coverage report
Added two maven profiles for:
- generating JaCoCo exec files
- generating JaCoCo reports
(cherry picked from commit 22b4755fbb
)
This commit is contained in:
parent
8e7d4fb34e
commit
c04fb0f7da
|
@ -5,6 +5,7 @@
|
||||||
* [IDE Integration](ide.md)
|
* [IDE Integration](ide.md)
|
||||||
* [Building](building.md)
|
* [Building](building.md)
|
||||||
* [Tests](tests.md)
|
* [Tests](tests.md)
|
||||||
|
* [Code coverage report](code-coverage-report.md)
|
||||||
* [Code Formatting](formatting.md)
|
* [Code Formatting](formatting.md)
|
||||||
* [Validating releases](validating-releases.md)
|
* [Validating releases](validating-releases.md)
|
||||||
* [Notes for Maintainers](maintainers.md)
|
* [Notes for Maintainers](maintainers.md)
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Code coverage report
|
||||||
|
|
||||||
|
## Getting JaCoCo exec files
|
||||||
|
|
||||||
|
Before you can generate code coverage report by JaCoCo tool,
|
||||||
|
you need to get data about what lines of code were executed
|
||||||
|
during testing. These information are collected by JaCoCo
|
||||||
|
agent and stored in JaCoCo exec files. All you need to do
|
||||||
|
is run the tests with `jacoco` maven profile.
|
||||||
|
|
||||||
|
```
|
||||||
|
mvn test -Ptests,extra-tests,jacoco
|
||||||
|
```
|
||||||
|
|
||||||
|
## Generate JaCoCo reports
|
||||||
|
|
||||||
|
```
|
||||||
|
mvn verify -Pjacoco-generate-report -DskipTests
|
||||||
|
```
|
||||||
|
|
||||||
|
For generating JaCoCo reports only run the maven build
|
||||||
|
with profile `jacoco-generate-report` as it is shown
|
||||||
|
in the example above. After the command was executed,
|
||||||
|
in directory `target/jacoco-report` you can find
|
||||||
|
reports in HTML and XML formats.
|
||||||
|
|
||||||
|
## Merge JaCoCo exec files to one
|
||||||
|
|
||||||
|
Since ActiveMQ Artemis is divided into several modules,
|
||||||
|
exec files are generated for each module separately.
|
||||||
|
If you need to merge them together to have all data
|
||||||
|
in one place, you can do it by command below.
|
||||||
|
|
||||||
|
```
|
||||||
|
mvn jacoco:merge -N -Pjacoco
|
||||||
|
```
|
||||||
|
|
186
pom.xml
186
pom.xml
|
@ -102,6 +102,8 @@
|
||||||
<arquillian-weld-embedded.version>2.0.0.Beta3</arquillian-weld-embedded.version>
|
<arquillian-weld-embedded.version>2.0.0.Beta3</arquillian-weld-embedded.version>
|
||||||
<owb.version>1.7.0</owb.version>
|
<owb.version>1.7.0</owb.version>
|
||||||
<arquillian.version>1.1.11.Final</arquillian.version>
|
<arquillian.version>1.1.11.Final</arquillian.version>
|
||||||
|
<version.org.jacoco>0.7.9</version.org.jacoco>
|
||||||
|
<version.org.jacoco.plugin>0.7.9</version.org.jacoco.plugin>
|
||||||
|
|
||||||
<owasp.version>1.4.3</owasp.version>
|
<owasp.version>1.4.3</owasp.version>
|
||||||
|
|
||||||
|
@ -148,10 +150,14 @@
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<!-- Property set by Jacoco plugin -->
|
||||||
|
<jacoco.agent></jacoco.agent>
|
||||||
|
|
||||||
<activemq-surefire-argline>-Djava.util.logging.manager=org.jboss.logmanager.LogManager
|
<activemq-surefire-argline>-Djava.util.logging.manager=org.jboss.logmanager.LogManager
|
||||||
-Dlogging.configuration="file:${activemq.basedir}/tests/config/logging.properties"
|
-Dlogging.configuration="file:${activemq.basedir}/tests/config/logging.properties"
|
||||||
-Djava.library.path="${activemq.basedir}/artemis-native/bin" -Djgroups.bind_addr=localhost -Dorg.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory.localBindAddress=localhost
|
-Djava.library.path="${activemq.basedir}/artemis-native/bin" -Djgroups.bind_addr=localhost -Dorg.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory.localBindAddress=localhost
|
||||||
-Djava.net.preferIPv4Stack=true
|
-Djava.net.preferIPv4Stack=true
|
||||||
|
@{jacoco.agent} -Djacoco.agent=@{jacoco.agent}
|
||||||
</activemq-surefire-argline>
|
</activemq-surefire-argline>
|
||||||
<activemq.basedir>${project.basedir}</activemq.basedir>
|
<activemq.basedir>${project.basedir}</activemq.basedir>
|
||||||
<skipLicenseCheck>true</skipLicenseCheck>
|
<skipLicenseCheck>true</skipLicenseCheck>
|
||||||
|
@ -648,6 +654,18 @@
|
||||||
<version>${arquillian.version}</version>
|
<version>${arquillian.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>org.jacoco.ant</artifactId>
|
||||||
|
<version>${version.org.jacoco}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>org.jacoco.core</artifactId>
|
||||||
|
<version>${version.org.jacoco}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.enterprise</groupId>
|
<groupId>javax.enterprise</groupId>
|
||||||
<artifactId>cdi-api</artifactId>
|
<artifactId>cdi-api</artifactId>
|
||||||
|
@ -947,6 +965,169 @@
|
||||||
<skipTests>true</skipTests>
|
<skipTests>true</skipTests>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
<!-- This profile generates jacoco coverage files. To generate html report use "-Pjacoco-generate-report" -->
|
||||||
|
<profile>
|
||||||
|
<id>jacoco</id>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>org.jacoco.core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>jacoco-prepare</id>
|
||||||
|
<phase>validate</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>prepare-agent</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<destFile>${project.build.directory}/jacoco.exec</destFile>
|
||||||
|
<!-- Jacoco sets this property with agent configuration.
|
||||||
|
This property is passed to maven-surefire-plugin -->
|
||||||
|
<propertyName>jacoco.agent</propertyName>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>merge</id>
|
||||||
|
<phase>none</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>merge</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<fileSets>
|
||||||
|
<fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">
|
||||||
|
<directory>${activemq.basedir}</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.exec</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
<!-- This profile generates html report from jacoco coverage files. Use "-Pjacoco" profile to generate coverage. -->
|
||||||
|
<profile>
|
||||||
|
<id>jacoco-generate-report</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<!-- Copy jacoco ant jar. This is needed to generate jacoco report with maven-antrun-plugin -->
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>copy</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>process-test-resources</phase>
|
||||||
|
<inherited>false</inherited>
|
||||||
|
<configuration>
|
||||||
|
<artifactItems>
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>org.jacoco.ant</artifactId>
|
||||||
|
<version>${version.org.jacoco.plugin}</version>
|
||||||
|
</artifactItem>
|
||||||
|
</artifactItems>
|
||||||
|
<stripVersion>true</stripVersion>
|
||||||
|
<outputDirectory>${project.build.directory}/jacoco-jars</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>post-integration-test</phase>
|
||||||
|
<goals><goal>run</goal></goals>
|
||||||
|
<inherited>false</inherited>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<property name="result.report.dir" location="target/jacoco-report"/>
|
||||||
|
<taskdef name="report" classname="org.jacoco.ant.ReportTask">
|
||||||
|
<classpath path="${project.build.directory}/jacoco-jars/org.jacoco.ant.jar"/>
|
||||||
|
</taskdef>
|
||||||
|
<echo>Creating JaCoCo ActiveMQ Artemis test coverage reports...</echo>
|
||||||
|
<report>
|
||||||
|
<executiondata>
|
||||||
|
<fileset dir="${basedir}">
|
||||||
|
<include name="**/target/jacoco.exec"/>
|
||||||
|
</fileset>
|
||||||
|
</executiondata>
|
||||||
|
<structure name="JaCoCo ActiveMQ Artemis">
|
||||||
|
<classfiles>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-boot/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-cdi-client/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-cli/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-commons/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-core-client/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-dto/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-jdbc-store/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-jms-client/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-jms-server/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-journal/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-native/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-ra/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-rest/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-selector/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-server/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-server-osgi/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-service-extensions/target"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-tools/target/classes"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-web/target/classes"/>
|
||||||
|
</classfiles>
|
||||||
|
<sourcefiles encoding="UTF-8">
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-boot/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-cdi-client/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-cli/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-commons/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-core-client/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-dto/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-jdbc-store/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-jms-client/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-jms-server/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-journal/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-native/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-ra/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-rest/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-selector/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-server/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-server-osgi/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-service-extensions/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-tools/src/main/java"/>
|
||||||
|
<fileset dir="${activemq.basedir}/artemis-web/src/main/java"/>
|
||||||
|
</sourcefiles>
|
||||||
|
</structure>
|
||||||
|
<html destdir="\${result.report.dir}"/>
|
||||||
|
<xml destfile="\${result.report.dir}/report.xml"/>
|
||||||
|
</report>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>org.jacoco.ant</artifactId>
|
||||||
|
<version>${version.org.jacoco.plugin}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -1191,6 +1372,11 @@
|
||||||
<artifactId>artemis-maven-plugin</artifactId>
|
<artifactId>artemis-maven-plugin</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<version>${version.org.jacoco.plugin}</version>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,11 @@ public final class SpawnedVMSupport {
|
||||||
commandList.add("-Djava.util.logging.config.file=" + loggingConfigFile + " ");
|
commandList.add("-Djava.util.logging.config.file=" + loggingConfigFile + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String jacocoAgent = System.getProperty("jacoco.agent");
|
||||||
|
if (jacocoAgent != null && !jacocoAgent.isEmpty()) {
|
||||||
|
commandList.add(jacocoAgent);
|
||||||
|
}
|
||||||
|
|
||||||
String loggingPlugin = System.getProperty("org.jboss.logging.Logger.pluginClass");
|
String loggingPlugin = System.getProperty("org.jboss.logging.Logger.pluginClass");
|
||||||
if (loggingPlugin != null) {
|
if (loggingPlugin != null) {
|
||||||
commandList.add("-Dorg.jboss.logging.Logger.pluginClass=" + loggingPlugin + " ");
|
commandList.add("-Dorg.jboss.logging.Logger.pluginClass=" + loggingPlugin + " ");
|
||||||
|
|
Loading…
Reference in New Issue