Jacoco Maven multi module project coverage

Reddy

Seems like there are couple of questions, which are quite old and things changed from Java 8 support of Jacoco.

My Project contains following structure

pom.xml
|
|
-----sub module A pom.xml
|
|
-----sub module B pom.xml
|
|
-----sub module C pom.xml

I have configured the main pom like this

Main POM.xml

<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>
    <groupId>com.test</groupId>
    <artifactId>jacoco-multi</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
        <module>projectA</module>
        <module>projectB</module>
    </modules>

    <properties>
        <jacoco.version>0.5.7.201204190339</jacoco.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit-dep</artifactId>
            <version>4.10</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>1.3.RC2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>1.3.RC2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.5.201505241946</version>
                <configuration>
                    <destFile>${project.basedir}/../target/jacoco.exec</destFile>
                    <append>true</append>
                </configuration>
                <executions>
                    <execution>
                        <id>jacoco-initialize</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jacoco-site</id>
                        <phase>package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.16</version>
                <executions>
                    <execution>
                        <id>default-integration-test</id>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
            </plugin>
        </plugins>
    </build>

</project>

A Pom.xml

<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>
    <parent>
        <artifactId>jacoco-multi</artifactId>
        <groupId>com.test</groupId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>..</relativePath>
    </parent>
    <artifactId>projectA</artifactId>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.12</version>
                </plugin>

            </plugins>
        </pluginManagement>
    </build>

</project>

B pom.xml

<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>
<parent>
    <artifactId>jacoco-multi</artifactId>
    <groupId>com.test</groupId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>..</relativePath>
</parent>
<artifactId>projectB</artifactId>

<dependencies>
    <dependency>
        <groupId>com.test</groupId>
        <artifactId>projectA</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
</dependencies>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

I am executing this command mvn clean package. I can see jacoco.exec is getting generated, however I am not able to see any HTML reports are being to verify the data.

Please help me with this. Another point is, my configuration is correct for Multi-Module projects?

Update

Identified issue. <destFile>${project.basedir}/../target/jacoco.exec</destFile> changed to <destFile>${project.basedir}/target/jacoco.exec</destFile>

Now it's generating reports for individual modules. Any idea how to generate consolidated report

Rogério

JaCoCo version 0.7.7 can generate an aggregate coverage report from multiple Maven modules through a new goal jacoco:report-aggregate.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Maven Multi Module Project Structuring Issues

From Dev

How to use Maven assembly plugin with multi module maven project

From Dev

Putting a multi-module Maven project into Jenkins

From Dev

Spring MVC in a multi maven module project

From Dev

Jboss as maven plugin to deploy Multi Module Maven Project

From Dev

Sonar maven jacoco code coverage for Multimodule project

From Dev

maven jacoco: not generating code coverage report

From Dev

Nar dependency in multi-module maven project

From Dev

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

From Dev

maven jacoco plugin does not generate coverage report

From Dev

How to create Maven Multi Module Project in Intellij?

From Dev

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

From Dev

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

From Dev

How to create Maven Multi Module Project in Intellij?

From Dev

Error resolving dependency for maven multi module project

From Dev

Using Enunciate in multi-module Maven project

From Dev

Spring MVC in a multi maven module project

From Dev

Coverage report of multi module project

From Dev

Convert maven project to submodule of multi module project?

From Dev

How to use Maven assembly plugin with multi module maven project

From Dev

Refactoring of maven multi module project in eclipse

From Dev

Multi-module project structure Maven

From Dev

Maven multi module project - start module from another module?

From Dev

Maven test lifecycle in a multi-module project

From Dev

Jacoco code coverage with Arquillian in Multi module project

From Dev

Find code coverage for multi module maven project

From Dev

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

From Dev

Sonar coverage always 0 in multi module project

From Dev

Creating multi module project using Intellij & Maven

Related Related

  1. 1

    Maven Multi Module Project Structuring Issues

  2. 2

    How to use Maven assembly plugin with multi module maven project

  3. 3

    Putting a multi-module Maven project into Jenkins

  4. 4

    Spring MVC in a multi maven module project

  5. 5

    Jboss as maven plugin to deploy Multi Module Maven Project

  6. 6

    Sonar maven jacoco code coverage for Multimodule project

  7. 7

    maven jacoco: not generating code coverage report

  8. 8

    Nar dependency in multi-module maven project

  9. 9

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

  10. 10

    maven jacoco plugin does not generate coverage report

  11. 11

    How to create Maven Multi Module Project in Intellij?

  12. 12

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

  13. 13

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

  14. 14

    How to create Maven Multi Module Project in Intellij?

  15. 15

    Error resolving dependency for maven multi module project

  16. 16

    Using Enunciate in multi-module Maven project

  17. 17

    Spring MVC in a multi maven module project

  18. 18

    Coverage report of multi module project

  19. 19

    Convert maven project to submodule of multi module project?

  20. 20

    How to use Maven assembly plugin with multi module maven project

  21. 21

    Refactoring of maven multi module project in eclipse

  22. 22

    Multi-module project structure Maven

  23. 23

    Maven multi module project - start module from another module?

  24. 24

    Maven test lifecycle in a multi-module project

  25. 25

    Jacoco code coverage with Arquillian in Multi module project

  26. 26

    Find code coverage for multi module maven project

  27. 27

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

  28. 28

    Sonar coverage always 0 in multi module project

  29. 29

    Creating multi module project using Intellij & Maven

HotTag

Archive