Here are the relevant snippets from the two POM files:
Dev: +++++++++++++++
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports-it/jacoco-it.exec</destFile>
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
Started Glassfish with the following JVM option :
-DargLine=-javaagent:C:/iat/mavenrepository/org/jacoco/org.jacoco.agent/0.7.9/org.jacoco.agent-0.7.9-runtime.jar=destfile=C:/mySampleApp/target/coverage-reports-it/jacoco-it.exec
Test POM: ++++++++++++++++++++++++++++++
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>C:/mySampleApp/target/coverage-reports-it/jacoco-it.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<argLine>-javaagent:c:\\iat\\mavenrepository\\org\\jacoco\\org.jacoco.agent\\0.7.9\\org.jacoco.agent-0.7.9-runtime.jar=destfile=C:\\mySampleApp\\target\\coverage-reports-it\\jacoco-it.exec</argLine>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
When I run mvn verify goal, it seems to be analyzing the files in the Test Maven project (and not the Dev project). Here is what I am seeing when I run the goal, can someone suggest what I am missing::
[INFO] Analyzed bundle 'JaxRsAppTest' with 3 classes
[WARNING] Classes in bundle 'mySampleAppTest' do no match with execution data. For report generation the same class files must be used as at runtime.
[WARNING] Execution data for class com/test/ServiceIntegrationTest does not match.
[WARNING] Execution data for class com/util/Common does not match.
[WARNING] Execution data for class com/util/RestClient does not match.
My goal is to analyze coverage for the Dev project.
Please note that I am able to see the expected coverage when the Dev project has both Unit and Integration tests. But my goal is to measure integration test coverage from a separate test project.
Thanks in advance.
Feel free to check out our solution here:
http://www.qalearningguide.com/2017/10/code-coverage-for-android-using-jacoco.html
We can definitely connect with the issue mentioned above.
Thanks,
Suparna