Cannot setup Arquillian + Jacoco test coverage
felipe.gdr Mar 13, 2013 9:10 AMHello!
I have been using arquillian tests with Jboss 7 Managed for a while now, and it works great!
Recently I'm trying to introduce test coverage on my project, so I've installed Sonar. I was able to get my unit tests covered, however, the Arquillian tests were not covered by Sonar "out-of-the-box". So I've did a search and stumbled some material over the subject
- http://techblog.joserodolfo.com/2011/07/arquillian-coverage-tests-reported-with-sonar-howto/ : basic guide on how to wire arquillian and jacoco together
- https://github.com/joserodolfofreitas/jacoco-integration-testcase/blob/master/pom.xml : example project using arquillian + jacoco + maven
After a few trying to put all this together, I got stuck. When I run mvn clean package my test get stuck and show no error on console...
Here is my pom:
<dependencies>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.0.3.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
</configuration>
</plugin>
<!-- <plugin> -->
<!-- <groupId>org.jacoco</groupId> -->
<!-- <artifactId>jacoco-maven-plugin</artifactId> -->
<!-- <version>0.5.3.201107060350</version> -->
<!-- <executions> -->
<!-- <execution> -->
<!-- <id>prepare-agent</id> -->
<!-- <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>
<!-- <reporting> -->
<!-- <plugins> -->
<!-- <plugin> -->
<!-- <groupId>org.jacoco</groupId> -->
<!-- <artifactId>jacoco-maven-plugin</artifactId> -->
<!-- <version>0.5.4.201111111111</version> -->
<!-- </plugin> -->
<!-- </plugins> -->
<!-- </reporting> -->
<profiles>
<profile>
<id>arquillian-jbossas-managed</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-dist</artifactId>
<version>7.1.1.Final</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>target</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- Ignore/Execute plugin execution -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<!-- copy-dependency plugin -->
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<directory>src/test/resources-jbossas-managed</directory>
</testResource>
</testResources>
</build>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<version>7.1.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
<!-- Dependências necessárias para integração do Arquillian com Jacoco -->
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-jacoco</artifactId>
<scope>test</scope>
<version>1.0.0.Alpha5</version>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.core</artifactId>
<version>0.5.3.201107060350</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
<repositories>
<repository>
<!-- for jacoco -->
<id>sonar</id>
<name>Sonar</name>
<url>http://repository.sonarsource.org/content/repositories/sonar</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
I was using jacoco's version 0.6.2.201302030002 but after reading the following post (https://community.jboss.org/message/715059) I've changed to version 0.5.3.201107060350, after that I started getting an ArtifactDescriptorException followed by several Missing artifact errors. It looks like this 0.5.3 version is not available at the central repo.
This post also made me remove the prepare-agent/report bits of my pom, but still I got no success.
I'm pretty sure I'm missing something. But frankly, I am finding really hard to find a comprehensive "how-to" on using the Arquillian-Jacoco extension.
Cheers!
Message was edited by: Felipe Reis