Jacoco code coverage with Arquillian in Multi module project

Raj

Anybody using Jacoco code coverage with Arquillian? My project is a multi module maven project and currently its not showing code coverage of Arquillian tests. Is there any additional changes in Arquillian.xml other than below pom changes?

Build and plugin part in my pom xml is below

  <build>
    <plugins>

      <!-- start Jacoco -->

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.4.201502262128</version>
    <configuration>
        <propertyName>coverageAgent</propertyName>
        <append>true</append>
    </configuration>
    <executions>
        <execution>
            <id>pre-unit-test</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
            <configuration>
                <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                <propertyName>surefireArgLine</propertyName>
                <append>true</append>
            </configuration>
        </execution>
        <execution>
            <id>post-unit-test</id>
            <phase>test</phase>
            <goals>
                <goal>report</goal>
            </goals>
            <configuration>
                <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                <outputDirectory>${project.basedir}/../target/coverageReport</outputDirectory>
                <append>true</append>
            </configuration>
        </execution>
        <execution>
            <id>pre-integration-test</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
            <configuration>
                <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
                <propertyName>failsafeArgLine</propertyName>
            </configuration>
        </execution>
        <execution>
            <id>post-integration-test</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>report</goal>
            </goals>
            <configuration>
                <append>true</append>
                <dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
                <outputDirectory>${project.basedir}/../target/coverageReport</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${maven.surefire.version}</version>
    <configuration>
        <argLine>${surefireArgLine}</argLine>
        <includes>
            <include>**/*TestNG*</include>
        </includes>
        <excludes>
            <exclude>**/Test/**</exclude>
            <exclude>**/*IT*</exclude>
        </excludes>
    </configuration>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.7.1</version>
    <configuration>
        <argLine>${failsafeArgLine}</argLine>
        <includes>
            <include>**/*Test*</include>
        </includes>
    </configuration>
</plugin>


     </plugins> 
   </build>  


 <profiles>
    <profile>
        <id>jacoco-integ-tests</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.7.1</version>
                    <configuration>
                        <argLine>${failsafeArgLine}</argLine>
                        <includes>
                            <include>**/*Test*</include>
                        </includes>
                        <properties>
                            <property>
                                <name>listener</name>
                                <value>org.sonar.java.jacoco.JUnitListener</value>
                            </property>
                        </properties>
                    </configuration>
                    <executions>
                            <execution>
                                <id>integration-tests</id>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                                <configuration>
                                    <argLine>${failsafeArgLine}</argLine>
                                    <properties>
                                <property>
                                    <name>listener</name>
                                    <value>org.sonar.java.jacoco.JUnitListener</value>
                                </property>
                            </properties>
                                    <skipTests>false</skipTests>
                                </configuration>
                            </execution>
                        </executions>
                </plugin>
            </plugins>
        </build>
        <dependencies>
            <dependency>
                <groupId>org.codehaus.sonar-plugins.java</groupId>
                <artifactId>sonar-jacoco-listeners</artifactId>
                <version>2.6</version>
                <scope>test</scope>
            </dependency>
            <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>1.0.0.Alpha9</version>
                 <scope>test</scope>
              </dependency>

        </dependencies>
    </profile>

    <profile>
        <id>jacoco-unit-tests</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.13</version>
                    <configuration>
                        <argLine>${surefireArgLine}</argLine>
                        <properties>
                            <property>
                                <name>listener</name>
                                <value>org.sonar.java.jacoco.TestNGListener</value>
                            </property>
                        </properties>
                        <includes>
                            <include>**/*TestNG*</include>
                        </includes>
                        <excludes>
                            <exclude>**/FT/**</exclude>
                            <exclude>**/*IT*</exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
        <dependencies>
            <dependency>
                <groupId>org.codehaus.sonar-plugins.java</groupId>
                <artifactId>sonar-jacoco-listeners</artifactId>
                <version>2.6</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>
</profiles>
Raj

Thanks @Godin for pointing me to the correct solution. I have resolved it by adding below two steps.

1) Parent pom

<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.7.8</version>
         <configuration>
            <destFile>${sonar.jacoco.itReportPath}</destFile>
            <append>true</append>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

2) In the child pom where integration Tests run

<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.8</version>
        <executions>
          <execution>
            <configuration>
              <destFile>${project.build.directory}/jacoco.exec</destFile>
            </configuration>
          </execution>
          <execution>
            <id>it-report</id>
            <phase>verify</phase>
            <goals>           
              <goal>report-aggregate</goal>
            </goals>
            <configuration>
            <!--   <dataFileIncludes>**/jacoco.exec</dataFileIncludes> -->
              <outputDirectory>${project.build.directory}/coverage-reports/jacoco</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

Key is we need to use "report-aggregate" goal instead of "report". "report-aggregate" goal can do multi module code coverage.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Jacoco Maven multi module project coverage

From Dev

How to check minimum code coverage for multi-module maven project with jacoco?

From Dev

Find code coverage for multi module maven project

From Dev

Integrating JaCoCo, Arquillian and REST Assured brings me a code coverage of 0%

From Dev

Gradle jacoco multi project. How to output the code coverage of all the project in the terminal?

From Dev

SonarQube not reading Integration JaCoCo Test coverage in parent pom target directory of a multi-module project

From Dev

Coverage report of multi module project

From Dev

Sonar maven jacoco code coverage for Multimodule project

From Dev

Cross-module code coverage with Jacoco offline instrumentation in gradle mutlimodule project

From Dev

Sonar coverage always 0 in multi module project

From Dev

jacoco code coverage of integration tests in a separate module in Netbeans

From Dev

Jacoco 0% Code Coverage

From Dev

java code coverage with jacoco

From Dev

Jacoco 0% Code Coverage

From Dev

Jacoco coverage of unit test code

From Dev

Jacoco Code Coverage in android studio

From Dev

Code coverage with jacoco for a Android library

From Dev

Jacoco code coverage is affected by AspectJ

From Dev

Missing Jacoco Code Coverage and IncompatibleClassChangeError

From Dev

Integrating scala code coverage tool jacoco into a play 2.2.x project

From Dev

Integrating scala code coverage tool jacoco into a play 2.2.x project

From Dev

Android - Jacoco code coverage ignores Robolectric tests

From Dev

maven jacoco: not generating code coverage report

From Dev

Gradle - Jacoco code coverage without running connectedCheck

From Dev

Why might Jacoco be showing a code coverage of 0?

From Dev

Minimum code coverage threshold in Jacoco Gradle

From Dev

How to check code coverage with JaCoCo agent?

From Dev

How to exclude a line from jacoco code coverage?

From Dev

Jacoco: Find code coverage for external tests

Related Related

  1. 1

    Jacoco Maven multi module project coverage

  2. 2

    How to check minimum code coverage for multi-module maven project with jacoco?

  3. 3

    Find code coverage for multi module maven project

  4. 4

    Integrating JaCoCo, Arquillian and REST Assured brings me a code coverage of 0%

  5. 5

    Gradle jacoco multi project. How to output the code coverage of all the project in the terminal?

  6. 6

    SonarQube not reading Integration JaCoCo Test coverage in parent pom target directory of a multi-module project

  7. 7

    Coverage report of multi module project

  8. 8

    Sonar maven jacoco code coverage for Multimodule project

  9. 9

    Cross-module code coverage with Jacoco offline instrumentation in gradle mutlimodule project

  10. 10

    Sonar coverage always 0 in multi module project

  11. 11

    jacoco code coverage of integration tests in a separate module in Netbeans

  12. 12

    Jacoco 0% Code Coverage

  13. 13

    java code coverage with jacoco

  14. 14

    Jacoco 0% Code Coverage

  15. 15

    Jacoco coverage of unit test code

  16. 16

    Jacoco Code Coverage in android studio

  17. 17

    Code coverage with jacoco for a Android library

  18. 18

    Jacoco code coverage is affected by AspectJ

  19. 19

    Missing Jacoco Code Coverage and IncompatibleClassChangeError

  20. 20

    Integrating scala code coverage tool jacoco into a play 2.2.x project

  21. 21

    Integrating scala code coverage tool jacoco into a play 2.2.x project

  22. 22

    Android - Jacoco code coverage ignores Robolectric tests

  23. 23

    maven jacoco: not generating code coverage report

  24. 24

    Gradle - Jacoco code coverage without running connectedCheck

  25. 25

    Why might Jacoco be showing a code coverage of 0?

  26. 26

    Minimum code coverage threshold in Jacoco Gradle

  27. 27

    How to check code coverage with JaCoCo agent?

  28. 28

    How to exclude a line from jacoco code coverage?

  29. 29

    Jacoco: Find code coverage for external tests

HotTag

Archive