Arquillian Extension Jacoco

Jacoco integration to add code coverage to Arquillian

License

License

Categories

Categories

JBoss Container Application Servers Arquillian Application Testing & Monitoring JaCoCo Code Coverage
GroupId

GroupId

org.jboss.arquillian.extension
ArtifactId

ArtifactId

arquillian-jacoco
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Arquillian Extension Jacoco
Jacoco integration to add code coverage to Arquillian
Project URL

Project URL

http://www.jboss.org/arquillian-jacoco
Project Organization

Project Organization

JBoss by Red Hat

Download arquillian-jacoco

How to add to project

<!-- https://jarcasting.com/artifacts/org.jboss.arquillian.extension/arquillian-jacoco/ -->
<dependency>
    <groupId>org.jboss.arquillian.extension</groupId>
    <artifactId>arquillian-jacoco</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.jboss.arquillian.extension/arquillian-jacoco/
implementation 'org.jboss.arquillian.extension:arquillian-jacoco:1.1.0'
// https://jarcasting.com/artifacts/org.jboss.arquillian.extension/arquillian-jacoco/
implementation ("org.jboss.arquillian.extension:arquillian-jacoco:1.1.0")
'org.jboss.arquillian.extension:arquillian-jacoco:jar:1.1.0'
<dependency org="org.jboss.arquillian.extension" name="arquillian-jacoco" rev="1.1.0">
  <artifact name="arquillian-jacoco" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.jboss.arquillian.extension', module='arquillian-jacoco', version='1.1.0')
)
libraryDependencies += "org.jboss.arquillian.extension" % "arquillian-jacoco" % "1.1.0"
[org.jboss.arquillian.extension/arquillian-jacoco "1.1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.jboss.shrinkwrap : shrinkwrap-api jar

provided (3)

Group / Artifact Type Version
org.jboss.arquillian.container : arquillian-container-spi jar
org.jboss.arquillian.container : arquillian-container-test-spi jar
org.jacoco : org.jacoco.core jar 0.8.5

test (9)

Group / Artifact Type Version
org.jboss.arquillian.junit : arquillian-junit-container jar
org.jboss.arquillian.protocol : arquillian-protocol-servlet jar
org.jboss.shrinkwrap.resolver : shrinkwrap-resolver-depchain pom
junit : junit jar
javax.enterprise : cdi-api jar 2.0
org.jboss.spec.javax.ejb : jboss-ejb-api_3.2_spec jar 1.0.2.Final
org.mockito : mockito-all jar 1.10.19
org.assertj : assertj-core jar 2.6.0
org.ow2.asm : asm-util jar 7.2

Project Modules

There are no modules declared in this project.

Build Status Maven Central

Arquillian Jacoco Extension

Automagic Remote InContainer Code Coverage

Usage

Maven default setup

Add the following to your pom.xml:

Set the versions to use:

...
<properties>
   <version.jacoco>0.8.5</version.jacoco>
   <version.arquillian_jacoco>1.1.0</version.arquillian_jacoco>
</properties>
...

Configure the Jacoco Maven plugin and depend on the Arquillian Jacoco Extension:

...
<profile>
   <id>jacoco</id>
   <dependencies>
      <dependency>
         <groupId>org.jacoco</groupId>
         <artifactId>org.jacoco.core</artifactId>
         <version>${version.jacoco}</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.jboss.arquillian.extension</groupId>
         <artifactId>arquillian-jacoco</artifactId>
         <version>${version.arquillian_jacoco}</version>
         <scope>test</scope>
      </dependency>
   </dependencies>
   <build>
      <plugins>
         <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${version.jacoco}</version>
            <executions>
               <execution>
                  <goals>
                     <goal>prepare-agent</goal>
                  </goals>
               </execution>
               <execution>
                  <id>report</id>
                  <phase>prepare-package</phase>
                  <goals>
                     <goal>report</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
</profile>

Activate this profile on command line by using the -P flag:

mvn test -Pjacoco

Please note that prepare-agent will set a property that is picked up by maven-surefire-plugin by default (see documentation).

Maven setup with shaded ASM and jacoco-core

JaCoCo requires ASM to work properly. Since ASM is also used by many other libraries like Apache CXF, you might run into version conflicts.
E.g. JBoss EAP 6.4 ships CXF 2.7 which requires ASM 3 but JaCoCo requires ASM 7+.

As a workaround, this extension provides an alternate with-asm flavour that includes "private" ASM and JaCoCo packages, shaded via maven-shade-plugin.

You only need a single dependency for this setup:

...
   <dependencies>
      <dependency>
         <groupId>org.jboss.arquillian.extension</groupId>
         <artifactId>arquillian-jacoco-with-asm</artifactId>
         <version>${version.arquillian_jacoco}</version>
         <scope>test</scope>
      </dependency>
   </dependencies>

Please note the absence of the jacoco-core dependency. This also means that it is not possible to choose a custom JaCoCo version.

(Optional) arquillian.xml

This extension can by configured via arquillian.xml, e.g.:

...
<extension qualifier="jacoco">
   <property name="includes">org.foo.*; org.bar.*</property>
   <property name="excludes">org.bar.baz.*</property>
   <property name="appendAsmLibrary">true</property>
</extension>

appendAsmLibrary will deploy the ASM library (which is used by JaCoCo) to the server. Defaults to true.
This can be set to false in case the container already provides a suitable version of ASM.
In case the with-asm flavour is used this property must be set to true.

Sonar

When using the Arquillian Jacoco Extension with Sonar you only need to depend on the Arquillian Jacoco Extension. Sonar will handle the setup of Jacoco for you.

org.jboss.arquillian.extension

An Innovative Testing Platform for the JVM

Versions

Version
1.1.0
1.0.0
1.0.0.Alpha10
1.0.0.Alpha9
1.0.0.Alpha8
1.0.0.Alpha7
1.0.0.Alpha6
1.0.0.Alpha5
1.0.0.Alpha4
1.0.0.Alpha3
1.0.0.Alpha2
1.0.0.Alpha1