I also have an integration test project that is a separate maven project and makes calls to the Dev project. In the POM of this project I am preparing the Java agent and am copying the .class files of the Dev project to a certain location under the target folder of the test project. The tests in this project make web service end points implemented in the Dev project and my goal is to get coverage when I run 'mvn verify'.
The issue here is when a report is generated there is no line level coverage even though the class level coverage seems accurate. Could you please point out what am I missing because of which the report is missing line level coverage.
TEST POM:
<build>
<finalName>JaxRsAppTest</finalName>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>initialize</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports-test/jacoco-test-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>
<dataFile>${project.build.directory}/coverage-reports-test/jacoco-test-it.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-test-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin> <!-- copies the Dev project's class files to the target of the test project>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>pre-integration-test</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>S:/JaxRsApp/Test/test-JaxRS/target/classes</outputDirectory>
<resources>
<resource>
<directory>S:/JaxRsApp/Dev/dmahapat_JaxRsApp/target/classes</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<argLine>${failsafeArgLine}</argLine>
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
Thanks in advance.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.abc.qe</groupId>
<artifactId>test-JaxRS</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>JaxRsAppTest</name>
<build>
<finalName>JaxRsAppTest</finalName>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>initialize</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports-test/jacoco-test-it.exec</destFile>
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>default-report</id>
<phase>verify</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<taskdef name="report" classname="org.jacoco.ant.ReportTask" classpathref="maven.plugin.classpath" />
<report>
<executiondata>
<file file="${project.build.directory}/coverage-reports-test/jacoco-test-it.exec" />
</executiondata>
<structure name="Coverage">
<classfiles>
<fileset dir="S:/JaxRsApp/Dev/dmahapat_JaxRsApp/target/classes"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="S:/JaxRsApp/Dev/dmahapat_JaxRsApp/src"/>
</sourcefiles>
</structure>
<check failonviolation="false" violationsproperty="violation">
<!--<rule element="BUNDLE">
<limit counter="INSTRUCTION" value="COVEREDRATIO" minimum="0.00" />
</rule>-->
</check>
<html destdir="${project.build.directory}/jacoco-internal"/>
</report>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.ant</artifactId>
<version>0.7.9</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.7</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Many thanks in advance.