Unable to generate code coverage for integration test module using jacoco

33 Views Asked by At

I have a maven project with the attached directory structure.

enter image description here

It contains a parent.pom and two modules.

  1. plugin 1.1 It contains the actual source code inside src/main 1.2 It contains the unit test cases inside src/test

  2. integration-tests 2.1 It contains all the integration tests for the plugin/src/main source code.

Now I am trying to add Jacoco Plugin to generate code coverage results that include all the unit and integration testcases.

My reports for the plugin module is getting generated but the one for the integration-tests is blank.

I am attaching all the POM.xml below.

Parent POM:

<?xml version="1.0" encoding="UTF-8"?>
<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>
        <groupId>com.atlassian.pom</groupId>
        <artifactId>public-pom</artifactId>
        <version>6.3.1</version>
    </parent>

    <groupId>com.atlassian.confluence.plugins.xmlrpc.bloggingrpc</groupId>
    <artifactId>bloggingrpc-parent</artifactId>
    <version>4.3.5-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>Confluence Blogging RPC Plugin Parent</name>
    <description>
        <![CDATA[Blogging API Plugin. This plugin contains an implementation of the Blogger 1.0 API and the MetaWeblog
        API that allows any clients that implement these APIs to post news items to confluence.]]>
    </description>
    <url>https://studio.plugins.atlassian.com/wiki/display/BLOG</url>

    <modules>
      <module>plugin</module>
      <module>integration-tests</module>
    </modules>

    <scm>
        <connection>scm:git:[email protected]:atlassian/confluence-blogging-rpc-plugin.git</connection>
        <developerConnection>scm:git:[email protected]:atlassian/confluence-blogging-rpc-plugin.git</developerConnection>
        <url>https://bitbucket.org/atlassian/confluence-blogging-rpc-plugin</url>
        <tag>HEAD</tag>
    </scm>

    <properties>
        <atlassian.plugin.key>com.atlassian.confluence.plugins.xmlrpc.bloggingrpc</atlassian.plugin.key>
        <confluence.version>8.6.0-rc1</confluence.version>
        <confluence.data.version>${confluence.version}</confluence.data.version>
        <atlassian.product.test-lib.version>3.0.0</atlassian.product.test-lib.version>
        
        <amps8.version>8.11.4</amps8.version>
        <jvm.args.custom /> <!-- Allows to specify custom arguments in build scripts -->
        <jvm.args.xmx>1024m</jvm.args.xmx>
        <jvm.args>-Xmx${jvm.args.xmx} ${jvm.args.custom}</jvm.args>
        
        <hamcrest.version>2.2</hamcrest.version>
        <containerId>tomcat9x</containerId>
        <server>localhost</server>

        <!-- For the flaky test reporter profile. -->
        <!-- override the versions of the listed plugins in amps -->
        <version.override.set>maven-failsafe-plugin</version.override.set>
        <!-- failsafe 2.20.1 or newer required for rerun support. Double check the version from the parent-pom -->
        <surefire.version>2.22.2</surefire.version>
        <download.maven.plugin.version>1.6.8</download.maven.plugin.version>
        <webdriver.browser>firefox</webdriver.browser>
        <failOnMilestoneOrReleaseCandidateDeps>false</failOnMilestoneOrReleaseCandidateDeps>
        <sonar-maven-plugin.version>3.11.0.3922</sonar-maven-plugin.version>
        <!-- SonarQube properties (these are inherited for each module) -->
        <sonar.links.issue>https://jira.atlassian.com/projects/CONFSRVDEV/issues</sonar.links.issue>
        <sonar.links.ci>https://server-syd-bamboo.internal.atlassian.com/allPlans.action</sonar.links.ci>
        <sonar.projectName>Confluence Blogging Rpc Plugin</sonar.projectName>
        <sonar.projectKey>confluence-blogging-rpc-plugin</sonar.projectKey>
        <!-- For multiple modules -->
        <sonar.moduleKey>${project.artifactId}</sonar.moduleKey>
    </properties>

    <profiles>
        <profile>
            <id>flaky</id>
            <properties>
                <ci.tests.skipAfterFailureCount>10</ci.tests.skipAfterFailureCount>
                <ci.tests.rerunFailingTestsCount>2</ci.tests.rerunFailingTestsCount>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.googlecode.maven-download-plugin</groupId>
                        <artifactId>download-maven-plugin</artifactId>
                        <version>${download.maven.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>download-flaky-configuration</id>
                                <phase>process-test-resources</phase>
                                <goals>
                                    <goal>wget</goal>
                                </goals>
                                <configuration>
                                    <url>https://s3-ap-southeast-2.amazonaws.com/confluence-server/bamboo/issuecreator_plugins_config.json</url>
                                    <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
                                    <overwrite>true</overwrite>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <skipAfterFailureCount>${ci.tests.skipAfterFailureCount}</skipAfterFailureCount>
                            <rerunFailingTestsCount>${ci.tests.rerunFailingTestsCount}</rerunFailingTestsCount>
                            <properties>
                                <property>
                                    <name>listener</name>
                                    <value>com.atlassian.test.reporting.JUnitFlakyTestListener</value>
                                </property>
                            </properties>
                            <systemPropertyVariables>
                                <junitflakylistener.runnerId>${env.bamboo_buildResultKey}</junitflakylistener.runnerId>
                                <junitflakylistener.branchName>${env.bamboo_planRepository_1_branchName}</junitflakylistener.branchName>
                                <!-- issue creation kill switch; by default, issues will be created on branch builds as well -->
                                <junitflakylistener.trackFlakyTest>true</junitflakylistener.trackFlakyTest>
                                <junitflakylistener.flakyTestFilePath>target/failsafe-reports/flakey-tests.txt</junitflakylistener.flakyTestFilePath>
                                <junitflakylistener.jiraProjectConfigPath>issuecreator_plugins_config.json</junitflakylistener.jiraProjectConfigPath>
                                <junitflakylistener.jiraUserName>${env.bamboo_issuecreator_jiraUserName}</junitflakylistener.jiraUserName>
                                <junitflakylistener.jiraPassword>${env.bamboo_issuecreator_jiraPassword}</junitflakylistener.jiraPassword>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>com.atlassian</groupId>
                    <artifactId>flaky-test-reporter</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>com.googlecode.maven-download-plugin</groupId>
                    <artifactId>download-maven-plugin</artifactId>
                    <version>${download.maven.plugin.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.drs</groupId>
                <artifactId>dependency-report-maven-plugin</artifactId>
                <version>1.5.17</version>
                <configuration>
                    <project>confluence-blogging-rpc-plugin</project>
                    <gracefulFailure>true</gracefulFailure>
                </configuration>
                <executions>
                    <execution>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>upload</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.sonarsource.scanner.maven</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>${sonar-maven-plugin.version}</version>
            </plugin>
        </plugins>
    </build>
</project>



Integration-test POM.xml

NOTE Since the source code is present inside plugins/ I have explicitly included the path in jacoco agent definition.

${project.basedir}/../plugin/**/*

<?xml version="1.0" encoding="UTF-8"?>
<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>
        <groupId>com.atlassian.confluence.plugins.xmlrpc.bloggingrpc</groupId>
        <artifactId>bloggingrpc-parent</artifactId>
        <version>4.3.5-SNAPSHOT</version>
    </parent>

    <artifactId>bloggingrpc-integration-tests</artifactId>

    <name>Confluence Blogging RPC Plugin Integration Tests</name>

    <properties>
        <sonar.tests>src/test</sonar.tests>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.atlassian.confluence</groupId>
                <artifactId>confluence-plugins-platform-test-pom</artifactId>
                <version>${confluence.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.atlassian.confluence.plugin</groupId>
                <artifactId>func-test-package</artifactId>
                <version>${atlassian.product.test-lib.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>com.atlassian.confluence.plugin</groupId>
                <artifactId>func-test</artifactId>
                <version>${atlassian.product.test-lib.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>com.google.inject</groupId>
                <artifactId>guice</artifactId>
                <version>5.1.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence-stateless-test-runner</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.selenium</groupId>
            <artifactId>atlassian-webdriver-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.10</version>
                <configuration>
                    <includes>
                        <include>${project.basedir}/../plugin/**/*</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <id>it-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>it-report</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report-integration</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>confluence-maven-plugin</artifactId>
                <version>${amps8.version}</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>webdriver-tests</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <extractDependencies>false</extractDependencies>
                    <containerId>${containerId}</containerId>
                    <jvmArgs>${jvm.args}</jvmArgs>
                    <productVersion>${confluence.version}</productVersion>
                    <productDataVersion>${confluence.data.version}</productDataVersion>
                    <server>${server}</server>
                    <output>${project.build.directory}/output.log</output>
                    <pluginArtifacts>
                        <pluginArtifact>
                            <groupId>com.atlassian.confluence.plugins.xmlrpc.bloggingrpc</groupId>
                            <artifactId>bloggingrpc</artifactId>
                            <version>${project.version}</version>
                        </pluginArtifact>
                    </pluginArtifacts>
                    <systemPropertyVariables>
                        <confluence.version>${confluence.version}</confluence.version> <!-- system property required by Functest RPC plugin -->
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Plugins POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>
        <groupId>com.atlassian.confluence.plugins.xmlrpc.bloggingrpc</groupId>
        <artifactId>bloggingrpc-parent</artifactId>
        <version>4.3.5-SNAPSHOT</version>
    </parent>

    <artifactId>bloggingrpc</artifactId>
    <packaging>atlassian-plugin</packaging>

    <name>Confluence Blogging RPC Plugin</name>

    <properties>
        <sonar.tests>src/test</sonar.tests>
        <sonar.sources>src/main</sonar.sources>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.atlassian.confluence</groupId>
                <artifactId>confluence-plugins-platform-pom</artifactId>
                <version>${confluence.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
      </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>net.sourceforge.cssparser</groupId>
                    <artifactId>cssparser</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>net.sourceforge.nekohtml</groupId>
                    <artifactId>nekohtml</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.10</version>
                <executions>
                    <execution>
                        <id>ut-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>ut-report</id>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>confluence-maven-plugin</artifactId>
                <version>${amps8.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <extractDependencies>false</extractDependencies>
                    <containerId>${containerId}</containerId>
                    <jvmArgs>${jvm.args}</jvmArgs>
                    <productVersion>${confluence.version}</productVersion>
                    <productDataVersion>${confluence.data.version}</productDataVersion>
                    <server>${server}</server>
                    <output>${project.build.directory}/output.log</output>
                    <systemPropertyVariables>
                        <webdriver.browser>${webdriver.browser}</webdriver.browser>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


when do I maven clean verify all unit tests and integration tests are getting executed.

The jacoco agent for plugins directory is getting the data from the classes

[INFO] 
[INFO] --- jacoco:0.8.10:report (ut-report) @ bloggingrpc ---
[INFO] Loading execution data file /Users/psaraiwala/Desktop/Packages/code_coverage/confluence/confluence-blogging-rpc-plugin/plugin/target/jacoco.exec
[INFO] Analyzed bundle 'Confluence Blogging RPC Plugin' with 4 classes
[INFO] 
[INFO] --< com.atlassian.confluence.plugins.xmlrpc.bloggingrpc:bloggingrpc-integration-tests >--
[INFO] Building Confluence Blogging RPC Plugin Integration Tests 4.3.5-SNAPSHOT [3/3]
[INFO]   from integration-tests/pom.xml

but the same for integration-tests is not working.

[INFO] --- jacoco:0.8.10:report-integration (it-report) @ bloggingrpc-integration-tests ---
[INFO] Loading execution data file /Users/psaraiwala/Desktop/Packages/code_coverage/confluence/confluence-blogging-rpc-plugin/integration-tests/target/jacoco-it.exec
[INFO] Analyzed bundle 'Confluence Blogging RPC Plugin Integration Tests' with 0 classes

NOTE This bundle does not contain any source code hence I included the source code of the plugin class in the agent definition .Still it is not working??

Tried chat-gpt as well. Couldn't find a working solution.

Kindly help!!!!

0

There are 0 best solutions below