1 2 Previous Next 18 Replies Latest reply on Jul 25, 2013 2:34 AM by javag

    Cannot setup Arquillian + Jacoco test coverage

    felipe.gdr

      Hello!

       

      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

        • 1. Re: Cannot setup Arquillian + Jacoco test coverage
          bmajsak

          Please try with 0.6.0.201210061924, this should work.

          • 2. Re: Cannot setup Arquillian + Jacoco test coverage
            felipe.gdr

            Thanks for the reply!

             

            I have changed the version as you suggested. Now I get no maven errors and I'm able to run my tests, however the Jacoco reports are not created...

             

            My updated pom looks like this:

             

            <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>

              </plugins>

              <pluginManagement>

              <plugins>

              <plugin>

                                                              <groupId>org.eclipse.m2e</groupId>

                                                              <artifactId>lifecycle-mapping</artifactId>

              <version>1.0.0</version>

              <configuration>

              <lifecycleMappingMetadata>

              <pluginExecutions>

              <pluginExecution>

              <pluginExecutionFilter>

                                                                                                                <groupId>org.apache.maven.plugins</groupId>

                                                                                                                <artifactId>maven-antrun-plugin</artifactId>

              <versionRange>[1.7,)</versionRange>

                                                                                                                <goals>

                                                                                                                          <goal>run</goal>

                                                                                                                </goals>

              </pluginExecutionFilter>

                                                                                                      <action>

                                                                                                                <ignore />

                                                                                                      </action>

              </pluginExecution>

              </pluginExecutions>

              </lifecycleMappingMetadata>

              </configuration>

              </plugin>

              </plugins>

              </pluginManagement>

            </build>

             

            <reporting>

              <plugins>

              <plugin>

                                                    <groupId>org.jacoco</groupId>

                                                    <artifactId>jacoco-maven-plugin</artifactId>

                                                    <version>0.6.0.201210061924</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>

              <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.6.0.201210061924</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>

            • 3. Re: Cannot setup Arquillian + Jacoco test coverage
              bmajsak

              Could share subset of the project through github so I can fork and fix if I find something?

              • 4. Re: Cannot setup Arquillian + Jacoco test coverage
                felipe.gdr

                The project is on bitbucket. Its a private repo, but I can share with you:

                 

                https://bitbucket.org/glrpopulis/populisii-repo.git

                 

                (sorry for the xml identation, I'm learning how to use the format tools on this forum).

                • 5. Re: Cannot setup Arquillian + Jacoco test coverage
                  felipe.gdr

                  Bartosz, I have set up a github project to facilitate the analyzis:

                   

                  https://github.com/felipe-gdr/populisII.git

                   

                  Thanks for your help.

                  • 6. Re: Cannot setup Arquillian + Jacoco test coverage
                    felipe.gdr

                    I was able to integrate arquillian + jacoco + sonar.

                     

                    Some important details that I was overlooking:

                     

                    - Maven 3 needs sonar-maven-plugin version 2.x

                    - Maven sonar:sonar won't work with remote servers, if the remote server uses the embedded Derby database (which is my case).

                    • 7. Re: Cannot setup Arquillian + Jacoco test coverage
                      javag

                      Hi Felipe, could you please share the final configuration which woked for you? I mean which version org.jacoco.core can be integrated with 1.0.0.Alpha5 arquillian-jacoco extension? Did you finally use jacoco-maven-plugin and with which goals, if any?

                      Thanks You in advance for your help.

                      • 8. Re: Cannot setup Arquillian + Jacoco test coverage
                        felipe.gdr

                        Hi javag.

                         

                        Setting up this test environment wasn't an easy task. I had to use a lot of trial and error, and I didn't really understand 100% of the process. So I'm posting my project's complete pom. I hope it will answer your current question as well as future questions you may have.

                         

                        <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">

                                  <modelVersion>4.0.0</modelVersion>

                         

                         

                                  <properties>

                                            <jacoco.version>0.6.0.201210061924</jacoco.version>

                                            <arquillian.jacoco.version>1.0.0.Alpha5</arquillian.jacoco.version>

                                  </properties>

                         

                         

                                  <dependencies>

                                            <!-- Common collections -->

                                            <dependency>

                                                      <groupId>commons-collections</groupId>

                                                      <artifactId>commons-collections</artifactId>

                                                      <version>3.2.1</version>

                                            </dependency>

                                            <!-- dependências de persistência -->

                                            <!-- JPA -->

                                            <dependency>

                                                      <groupId>org.hibernate.javax.persistence</groupId>

                                                      <artifactId>hibernate-jpa-2.0-api</artifactId>

                                                      <version>1.0.1.Final</version>

                                            </dependency>

                                            <!-- gerador de metamodel do hibernate

                                            <dependency>

                                                      <groupId>org.hibernate</groupId>

                                                      <artifactId>hibernate-jpamodelgen</artifactId>

                                                      <version>1.2.0.Final</version>

                                            </dependency>

                                             -->

                                            <!-- Easy Criteria: ferramenta para facilitar uso de criteria -->

                                            <dependency>

                                                      <groupId>uaihebert.com</groupId>

                                                      <artifactId>EasyCriteria</artifactId>

                                                      <version>2.1.0</version>

                                            </dependency>

                                            <!-- fim dependências de JPA -->

                                            <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>

                                            <!-- Dependencia do Arquillian http://arquillian.org/guides/getting_started/ -->

                                            <dependency>

                                                      <groupId>org.jboss.arquillian.junit</groupId>

                                                      <artifactId>arquillian-junit-container</artifactId>

                                                      <scope>test</scope>

                                            </dependency>

                                            <!-- Dependencia do Arquillian http://arquillian.org/guides/getting_started/ -->

                         

                         

                                            <!-- Usada para facilitar reflexão: bean validator maiorQue -->

                                            <dependency>

                                                      <groupId>commons-beanutils</groupId>

                                                      <artifactId>commons-beanutils</artifactId>

                                                      <version>1.8.3</version>

                                            </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>

                                                                          <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=512m</argLine>

                                                                </configuration>

                                                      </plugin>

                                                      <plugin>

                                                                <groupId>org.apache.maven.plugins</groupId>

                                                                <artifactId>maven-antrun-plugin</artifactId>

                                                                <version>1.7</version>

                                                                <executions>

                                                                          <execution>

                                                                                    <id>cria-persistence-xml</id>

                                                                                    <phase>validate</phase>

                                                                                    <configuration>

                                                                                              <target>

                                                                                                        <echo>Banco de dados selecionado : ${banco.dados}</echo>

                                                                                                        <copy overwrite="true"

                                                                                                                  file="persistences-xml/${banco.dados}-persistence.xml" tofile="src/main/resources/META-INF/persistence.xml" />

                                                                                                        <replace file="src/main/resources/META-INF/persistence.xml"

                                                                                                                  token="#catalog" value="${catalog}" />

                                                                                                        <replace file="src/main/resources/META-INF/persistence.xml"

                                                                                                                  token="#schema" value="${schema}" />

                                                                                              </target>

                                                                                    </configuration>

                                                                                    <goals>

                                                                                              <goal>run</goal>

                                                                                    </goals>

                                                                          </execution>

                                                                </executions>

                                                      </plugin>

                                                      <plugin>

                                                                <groupId>org.jacoco</groupId>

                                                                <artifactId>jacoco-maven-plugin</artifactId>

                                                                <version>${jacoco.version}</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>

                                            <pluginManagement>

                                                      <plugins>

                                                                <!--This plugin's configuration is used to store Eclipse m2e settings

                                                                          only. It has no influence on the Maven build itself. -->

                                                                <plugin>

                                                                          <groupId>org.eclipse.m2e</groupId>

                                                                          <artifactId>lifecycle-mapping</artifactId>

                                                                          <version>1.0.0</version>

                                                                          <configuration>

                                                                                    <lifecycleMappingMetadata>

                                                                                              <pluginExecutions>

                                                                                                        <pluginExecution>

                                                                                                                  <pluginExecutionFilter>

                                                                                                                            <groupId>org.apache.maven.plugins</groupId>

                                                                                                                            <artifactId>maven-antrun-plugin</artifactId>

                                                                                                                            <versionRange>[1.7,)</versionRange>

                                                                                                                            <goals>

                                                                                                                                      <goal>run</goal>

                                                                                                                            </goals>

                                                                                                                  </pluginExecutionFilter>

                                                                                                                  <action>

                                                                                                                            <ignore />

                                                                                                                  </action>

                                                                                                        </pluginExecution>

                                                                                                        <!-- <pluginExecution> -->

                                                                                                        <!-- <pluginExecutionFilter> -->

                                                                                                        <!-- <groupId>org.jacoco</groupId> -->

                                                                                                        <!-- <artifactId> -->

                                                                                                        <!-- jacoco-maven-plugin -->

                                                                                                        <!-- </artifactId> -->

                                                                                                        <!-- <versionRange> -->

                                                                                                        <!-- [0.5.3.201107060350,) -->

                                                                                                        <!-- </versionRange> -->

                                                                                                        <!-- <goals> -->

                                                                                                        <!-- <goal>prepare-agent</goal> -->

                                                                                                        <!-- </goals> -->

                                                                                                        <!-- </pluginExecutionFilter> -->

                                                                                                        <!-- <action> -->

                                                                                                        <!-- <ignore></ignore> -->

                                                                                                        <!-- </action> -->

                                                                                                        <!-- </pluginExecution> -->

                                                                                                        <pluginExecution>

                                                                                                                  <pluginExecutionFilter>

                                                                                                                            <groupId>org.jacoco</groupId>

                                                                                                                            <artifactId>

                                                                                                                                      jacoco-maven-plugin

                                                                                                                            </artifactId>

                                                                                                                            <versionRange>

                                                                                                                                      [0.6.0.201210061924,)

                                                                                                                            </versionRange>

                                                                                                                            <goals>

                                                                                                                                      <goal>prepare-agent</goal>

                                                                                                                            </goals>

                                                                                                                  </pluginExecutionFilter>

                                                                                                                  <action>

                                                                                                                            <ignore></ignore>

                                                                                                                  </action>

                                                                                                        </pluginExecution>

                                                                                              </pluginExecutions>

                                                                                    </lifecycleMappingMetadata>

                                                                          </configuration>

                                                                </plugin>

                                                      </plugins>

                                            </pluginManagement>

                                  </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>

                                                                          <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>${arquillian.jacoco.version}</version>

                                                                </dependency>

                                                                <dependency>

                                                                          <groupId>org.jacoco</groupId>

                                                                          <artifactId>org.jacoco.core</artifactId>

                                                                          <version>${jacoco.version}</version>

                                                                          <scope>test</scope>

                                                                </dependency>

                                                                <dependency>

                                                                          <groupId>org.jboss.arquillian.junit</groupId>

                                                                          <artifactId>arquillian-junit-container</artifactId>

                                                                          <scope>test</scope>

                                                                </dependency>

                                                                <!-- Dependências necessárias para integração do Arquillian com Sonar -->

                                                      </dependencies>

                                            </profile>

                                  </profiles>

                        </project>

                        • 9. Re: Cannot setup Arquillian + Jacoco test coverage
                          javag

                          Hi Felipe, thank you for sharing, yet this version of jacoco didn't work for me, got this exception:

                           

                          java.lang.NoSuchMethodException: org.jacoco.agent.rt.internal_9dd1198.core.runtime.RuntimeData.getExecutionData([Ljava.lang.Object;)

                           

                          Looking at jacoco.core library I see there is no such class RuntimeData at all - that's the problem of all other jacoco.core versions too, including the latest one, I tried to get working with arquillian-jacoco extension 1.0.0.Alpha5, although each time got different missing class/method.

                          So I wonder how it could be working at your side

                          Thanks anyway for your help.

                          • 10. Re: Cannot setup Arquillian + Jacoco test coverage
                            felipe.gdr

                            That's weird javag. Are you using the same versions as in the pom I've posted?

                            • 11. Re: Cannot setup Arquillian + Jacoco test coverage
                              javag

                              Weird indeed. I tried exactly the same version of org.jacoco.core as you do and got this NoSuchMethodException exception. If you look into contents of your org.jacoco.core-0.6.0.201210061924.jar under Maven Dependencies, do you see the class RuntimeData under runtime package? In my library it's just not there, so no surprize I get this exception. Besides, all other jacoc-related configurations I see in your pom.xml look pretty the same as I have in mine. Meanwhile I stopped trying, because I just didn't find any jacoco.core version compatible with arquillian-jacoco 1.0.0.Alpha5.

                              BTW - do you get reliable coverage results, if it works for you?

                              • 12. Re: Cannot setup Arquillian + Jacoco test coverage
                                felipe.gdr

                                I don't see this class neither. The test results are pretty reliable. I have successfuly integrated arquillian, jacoco, sonar, and bamboo. Everything is working fine...

                                 

                                Captura de Tela 2013-07-04 às 09.47.56.png

                                • 13. Re: Cannot setup Arquillian + Jacoco test coverage
                                  javag

                                  Yep, it seems exactly the same runtime package as I have. How do you run your arquillian tests? Currently I'm trying to run it manually via JUnit Runner in my Eclipse IDE: Run As => JUnit Test, so I suspect the problem occurs when arquillian tries to pass the tests results to ecl-emma/jacoco agent. Do you run your tests from within IDE, or just by maven command line?

                                   

                                  java.lang.NoSuchMethodException: org.jacoco.agent.rt.internal_9dd1198.core.runtime.RuntimeData.getExecutionData([Ljava.lang.Object;)

                                            at java.lang.Class.getDeclaredMethod(Class.java:1954)

                                  at org.jboss.arquillian.extension.jacoco.client.CoverageDataReceiver.copyToAgentExecutionStore(CoverageDataReceiver.java:46)

                                            at org.jboss.arquillian.extension.jacoco.client.CoverageDataReceiver.storeCoverageData(CoverageDataReceiver.java:30)

                                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                                            at java.lang.reflect.Method.invoke(Method.java:601)

                                            at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                                            at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

                                            at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

                                            at org.jboss.arquillian.container.test.impl.client.container.command.ContainerCommandObserver.onException(ContainerCommandObserver.java:43)

                                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                                            at java.lang.reflect.Method.invoke(Method.java:601)

                                            at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                                            at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                                            at org.jboss.arquillian.container.test.impl.client.deployment.command.DeploymentCommandObserver.onException(DeploymentCommandObserver.java:51)

                                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                                            at java.lang.reflect.Method.invoke(Method.java:601)

                                            at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

                                            at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                                            at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

                                            at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

                                            at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

                                            at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter$1.fired(RemoteTestExecuter.java:149)

                                            at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor$1.run(ServletMethodExecutor.java:105)

                                            at java.util.TimerThread.mainLoop(Timer.java:555)

                                            at java.util.TimerThread.run(Timer.java:505)

                                  • 14. Re: Cannot setup Arquillian + Jacoco test coverage
                                    felipe.gdr

                                    I run from Eclipse, maven, bamboo... They all work fine.

                                     

                                    Are you using an embedded or managed server? Is it JBoss or Glassfish?

                                     

                                    I use embedded JBoss.

                                    1 2 Previous Next