Analyze coverage of dev project from a separate integration test project.

49 views
Skip to first unread message

pran...@hotmail.com

unread,
Oct 18, 2017, 4:30:18 PM10/18/17
to JaCoCo and EclEmma Users
Hi,
I have written a simple Java Web Service and have deployed it onto Glassfish.
I have created a separate test project that calls the web service end points that are in the dev project.

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.

Message has been deleted

supar...@gmail.com

unread,
Nov 15, 2017, 6:29:31 AM11/15/17
to JaCoCo and EclEmma Users
Hi,
We were working on this some times back and realized that not much help is available in internet over this issue.

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

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages