activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-1265 JaCoCo profile for getting code coverage report
Date Mon, 24 Jul 2017 14:14:04 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 32c54d594 -> ae41b72e3


ARTEMIS-1265 JaCoCo profile for getting code coverage report

Added two maven profiles for:
 - generating JaCoCo exec files
 - generating JaCoCo reports


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/22b4755f
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/22b4755f
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/22b4755f

Branch: refs/heads/master
Commit: 22b4755fbbfd680a0ef979781c3f046e930837c1
Parents: 32c54d5
Author: Erich Duda <eduda@redhat.com>
Authored: Wed Jun 28 16:18:28 2017 +0200
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Mon Jul 24 09:56:08 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/22b4755f/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/22b4755f/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/22b4755f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ae4bc22..81f5196 100644
--- a/pom.xml
+++ b/pom.xml
@@ -105,6 +105,8 @@
       <owb.version>1.7.0</owb.version>
       <arquillian.version>1.1.11.Final</arquillian.version>
       <servicemix.json-1.1.spec.version>2.9.0</servicemix.json-1.1.spec.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>
 
@@ -151,11 +153,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 -Dbasedir=${basedir}
+         @{jacoco.agent} -Djacoco.agent=@{jacoco.agent}
       </activemq-surefire-argline>
       <activemq.basedir>${project.basedir}</activemq.basedir>
       <skipLicenseCheck>true</skipLicenseCheck>
@@ -661,6 +667,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>
@@ -950,6 +968,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>
@@ -1195,6 +1376,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/22b4755f/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 c1153bc..e66da2c 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
@@ -118,6 +118,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 + " ");


Mime
View raw message