You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/08/02 16:52:06 UTC
[4/4] activemq-artemis git commit: ARTEMIS-1265 JaCoCo profile for
getting code coverage report
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 22b4755fbbfd680a0ef979781c3f046e930837c1)
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/c04fb0f7
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/c04fb0f7
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/c04fb0f7
Branch: refs/heads/1.x
Commit: c04fb0f7da97dc411b514ab3e25d1e3d3b54c7d7
Parents: 8e7d4fb
Author: Erich Duda <ed...@redhat.com>
Authored: Wed Jun 28 16:18:28 2017 +0200
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Aug 2 12:51:57 2017 -0400
----------------------------------------------------------------------
docs/hacking-guide/en/SUMMARY.md | 1 +
docs/hacking-guide/en/code-coverage-report.md | 37 ++++
pom.xml | 186 +++++++++++++++++++
.../artemis/tests/util/SpawnedVMSupport.java | 5 +
4 files changed, 229 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c04fb0f7/docs/hacking-guide/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/hacking-guide/en/SUMMARY.md b/docs/hacking-guide/en/SUMMARY.md
index 376abaa..555605f 100644
--- a/docs/hacking-guide/en/SUMMARY.md
+++ b/docs/hacking-guide/en/SUMMARY.md
@@ -5,6 +5,7 @@
* [IDE Integration](ide.md)
* [Building](building.md)
* [Tests](tests.md)
+* [Code coverage report](code-coverage-report.md)
* [Code Formatting](formatting.md)
* [Validating releases](validating-releases.md)
* [Notes for Maintainers](maintainers.md)
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c04fb0f7/docs/hacking-guide/en/code-coverage-report.md
----------------------------------------------------------------------
diff --git a/docs/hacking-guide/en/code-coverage-report.md b/docs/hacking-guide/en/code-coverage-report.md
new file mode 100644
index 0000000..9984b7d
--- /dev/null
+++ b/docs/hacking-guide/en/code-coverage-report.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
+```
+
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c04fb0f7/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 87d0bdc..b101839 100644
--- a/pom.xml
+++ b/pom.xml
@@ -102,6 +102,8 @@
<arquillian-weld-embedded.version>2.0.0.Beta3</arquillian-weld-embedded.version>
<owb.version>1.7.0</owb.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>
@@ -147,11 +149,15 @@
-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:StartFlightRecording=delay=30s,duration=120s,filename=/tmp/myrecording.jfr
-->
+
+ <!-- Property set by Jacoco plugin -->
+ <jacoco.agent></jacoco.agent>
<activemq-surefire-argline>-Djava.util.logging.manager=org.jboss.logmanager.LogManager
-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.net.preferIPv4Stack=true
+ @{jacoco.agent} -Djacoco.agent=@{jacoco.agent}
</activemq-surefire-argline>
<activemq.basedir>${project.basedir}</activemq.basedir>
<skipLicenseCheck>true</skipLicenseCheck>
@@ -649,6 +655,18 @@
<scope>test</scope>
</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>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>${cdi-api.version}</version>
@@ -947,6 +965,169 @@
<skipTests>true</skipTests>
</properties>
</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>
<build>
@@ -1191,6 +1372,11 @@
<artifactId>artemis-maven-plugin</artifactId>
<version>${project.version}</version>
</plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>${version.org.jacoco.plugin}</version>
+ </plugin>
</plugins>
</pluginManagement>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c04fb0f7/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java
index 703c848..a8593f2 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java
@@ -110,6 +110,11 @@ public final class SpawnedVMSupport {
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");
if (loggingPlugin != null) {
commandList.add("-Dorg.jboss.logging.Logger.pluginClass=" + loggingPlugin + " ");