4 Replies Latest reply on Sep 4, 2013 8:40 AM by Karel Piwko

    How to generate Code Coverage reports from Drone tests

    Felipe Reis Newbie

      My project is composed by a EJB module and a Web module.

       

      The EJB module uses Arquillian with Persistence extension to run integration tests. Arquillian starts up a managed Jboss7, setup the database, run the tests and then shuts down Jboss. I have JaCoCo Maven Plugin configured to generated code coverage reports for those tests and everything is working perfectly - reports are created and exported to a sonar server.

       

      The Web module uses Arquillian with Drone/Graphene extensions to run Selenium tests. So, during my CI build, Arquillian starts a Jboss7, starts firefox and run the Selenium test suites automatically. Here is where I'm having troubles... All the tests run just fine, however JaCoCo reports are not being generated for this module.

       

      Both modules share a common root pom, here is the relevant bit of this pom:

       

          <project
          xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          
          <properties>
          <version.joda.time>2.1</version.joda.time>
          <version.junit>4.11</version.junit>
          <version.mockito>1.9.5</version.mockito>
          <version.jacoco>0.6.0.201210061924</version.jacoco>
          <version.arquillian.jacoco>1.0.0.Alpha5</version.arquillian.jacoco>
          <version.arquillian.persistence>1.0.0.Alpha6</version.arquillian.persistence>
          <version.commons.collections>3.2.1</version.commons.collections>
          <version.guava.testlib>14.0.1</version.guava.testlib>
          </properties>
          
          <dependencies>
          <dependency>
          <groupId>joda-time</groupId>
          <artifactId>joda-time</artifactId>
          <version>${version.joda.time}</version>
          </dependency>
          <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>${version.junit}</version>
          <scope>test</scope>
          </dependency>
          <dependency>
          <groupId>org.mockito</groupId>
          <artifactId>mockito-all</artifactId>
          <version>${version.mockito}</version>
          <scope>test</scope>
          </dependency>
          <dependency>
          <groupId>com.google.guava</groupId>
          <artifactId>guava-testlib</artifactId>
          <version>${version.guava.testlib}</version>
          <scope>test</scope>
          </dependency>
          <dependency>
          <groupId>commons-collections</groupId>
          <artifactId>commons-collections</artifactId>
          <version>${version.commons.collections}</version>
          </dependency>
          </dependencies>
          
          <dependencyManagement>
          <dependencies>
          <dependency>
          <groupId>org.jboss.arquillian.extension</groupId>
          <artifactId>arquillian-drone-bom</artifactId>
          <version>1.2.0.Alpha2</version>
          <type>pom</type>
          <scope>import</scope>
          </dependency>
          <dependency>
          <groupId>org.jboss.arquillian</groupId>
          <artifactId>arquillian-bom</artifactId>
          <version>1.0.4.Final</version>
          <scope>import</scope>
          <type>pom</type>
          </dependency>
          </dependencies>
          </dependencyManagement>
          
          <build>
          <plugins>
          <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${version.jacoco}</version>
          <executions>
          <execution>
          <id>pre-unit-test</id>
          <goals>
          <goal>prepare-agent</goal>
          </goals>
          </execution>
          <execution>
          <id>post-unit-test</id>
          <phase>test</phase>
          <goals>
          <goal>report</goal>
          </goals>
          </execution>
          <execution>
          <id>pre-integration-test</id>
          <phase>pre-integration-test</phase>
          <goals>
          <goal>prepare-agent</goal>
          </goals>
          <configuration>
          <destFile>target/jacoco-it.exec</destFile>
          <propertyName>failsafe.argLine</propertyName>
          </configuration>
          </execution>
          <execution>
          <id>post-integration-test</id>
          <phase>post-integration-test</phase>
          <goals>
          <goal>report</goal>
          </goals>
          <configuration>
          <dataFile>target/jacoco-it.exec</dataFile>
          </configuration>
          </execution>
          </executions>
          </plugin>
          <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.14</version>
          <configuration>
          <argLine>${failsafe.argLine}</argLine>
          <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
          </configuration>
          <executions>
          <execution>
          <id>integration-test</id>
          <goals>
          <goal>integration-test</goal>
          </goals>
          </execution>
          <execution>
          <id>verify</id>
          <goals>
          <goal>verify</goal>
          </goals>
          </execution>
          </executions>
          </plugin>
          <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.0</version>
          <configuration>
          <source>1.7</source>
          <target>1.7</target>
          <encoding>UTF-8</encoding>
          </configuration>
          </plugin>
          <plugin>
          <groupId>com.atlassian.maven.plugins</groupId>
          <artifactId>maven-jgitflow-plugin</artifactId>
          <version>1.0-alpha14</version>
          <configuration>
          <enableFeatureVersions>true</enableFeatureVersions>
          <autoVersionSubmodules>true</autoVersionSubmodules>
          <pushReleases>true</pushReleases>
          </configuration>
          </plugin>
          </plugins>
          </build>
          
          <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>
          </testResources>
          </build>
          <dependencies>
          <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>
          <dependency>
          <groupId>org.jboss.arquillian.extension</groupId>
          <artifactId>arquillian-jacoco</artifactId>
          <scope>test</scope>
          <version>${version.arquillian.jacoco}</version>
          </dependency>
          <dependency>
          <groupId>org.jacoco</groupId>
          <artifactId>org.jacoco.core</artifactId>
          <version>${version.jacoco}</version>
          <scope>test</scope>
          </dependency>
          <dependency>
          <groupId>org.jboss.arquillian.junit</groupId>
          <artifactId>arquillian-junit-container</artifactId>
          <scope>test</scope>
          </dependency>
          <dependency>
          <groupId>org.jboss.arquillian.junit</groupId>
          <artifactId>arquillian-junit-container</artifactId>
          <scope>test</scope>
          </dependency>
          <dependency>
          <groupId>org.jboss.arquillian.extension</groupId>
          <artifactId>arquillian-persistence-impl</artifactId>
          <version>${version.arquillian.persistence}</version>
          <scope>test</scope>
          </dependency>
          </dependencies>
          </profile>
          </profiles>
          
          </project>