Unable to get Jacoco coverage with Arquillian tests
sursini Jun 6, 2013 8:00 AMI'm managing a multi-module project with module tests implemented with Arquillian.
The structure of the project is the following
| Maven Project Structure |
|---|
+- Root Pom (root level) +- Server 1 (Second level) +-Web service module 1 (Third level) +-EJB module 2 +- Server 2 +-Web service module 1 .... |
In my root pom.xml we have the following configuration :
<project>
...
<properties>
...
<jacoco.version>0.6.0.201210061924</jacoco.version>
</properties>
<profiles>
<profile>
<id>integration-tests</id>
<!-- activated only for third level modules -->
<activation>
<file>
<exists>../../pom.xml</exists>
</file>
</activation>
<properties>
<sonar.jacoco.reportPath>../../target/jacoco.exec
</sonar.jacoco.reportPath>
<sonar.jacoco.itReportPath>../../target/jacoco-it.exec
</sonar.jacoco.itReportPath>
<sonar.dynamicAnalysis>reuseReports
</sonar.dynamicAnalysis>
<sonar.core.codeCoveragePlugin>jacoco
</sonar.core.codeCoveragePlugin>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.extension
</groupId>
<artifactId>arquillian-jacoco</artifactId>
<version>1.0.0.Alpha5</version>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.core</artifactId>
<version>${jacoco.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin
</artifactId>
<version>2.14.1</version>
<inherited>true</inherited>
<configuration>
<argLine>${coverageAgent}</argLine>
<enableAssertions>true
</enableAssertions>
<systemPropertyVariables>
<arquillian.launch>jenkins
</arquillian.launch>
</systemPropertyVariables>
<testFailureIgnore>true
</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<configuration>
<destFile>${sonar.jacoco.reportPath}
</destFile>
<dataFile>${sonar.jacoco.reportPath}
</dataFile>
<output>file</output>
<append>true</append>
<propertyName>coverageAgent</propertyName>
</configuration>
<executions>
<execution>
<id>jacoco-prepare</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
My arquillian.xml contains the following :
<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> <defaultProtocol type="Servlet 3.0" > <property name="executionType">MANAGED</property> </defaultProtocol> <container qualifier="jboss" default="true"> <configuration> <property name="serverConfig">standalone.xml</property> <property name="allowConnectingToRunningServer">true</property> </configuration> </container> <container qualifier="jenkins" default="false"> <configuration> <property name="serverConfig">standalone.xml</property> <property name="javaVmArguments">-Xms64m -Xmx1024m -XX:MaxPermSize=512m -Djboss.socket.binding.port-offset=8000</property> <property name="allowConnectingToRunningServer">false</property> <property name="managementPort">17999</property> <property name="jbossHome">target/jboss-as-7.1.1.Final</property> </configuration> </container> <extension qualifier="persistence-dbunit"> <property name="datatypeFactory">org.dbunit.ext.h2.H2DataTypeFactory</property> </extension> <!-- Probably useless --> <extension qualifier="jacoco"> <property name="includes">com.mydomain.*</property> </extension> </arquillian>
When I execute the test (in the following example for one module only) :
mvn test -pl :<third level artifactId>
I get the jacoco.exe file created in <root folder>/target/jacoco.exec as expected
But when I try to execute the report using the jacoco-maven-plugin
mvn org.jacoco:jacoco-maven-plugin:0.6.0.201210061924:report -DdataFile="target/jacoco.exec"
I got the coverage of the JUnit test but nothing about the Arquillian tests.
I tried to play with the jacoco versions and i used the Servlet 3.0 protocol without success.
Thanks in advance for your help