Code coverage for integration test of api

44 views
Skip to first unread message

devikas...@gmail.com

unread,
Sep 3, 2019, 2:40:00 AM9/3/19
to JaCoCo and EclEmma Users
Does Jacoco provide code coverage for integration tests of APIs? That is, I have an instance of my application running locally and I have integration tests where I hit an api offered by my running application instance. In this scenario can I use Jacoco to get how many lines of my running application instance was covered when integration tests where ran?

Marc Hoffmann

unread,
Sep 5, 2019, 1:10:26 AM9/5/19
to jac...@googlegroups.com
You can collect execution data from any Java application.

All you need to do ist to configure the JaCoCo agent for the application under test. See documentation:


Regards,
-marc

On 3. Sep 2019, at 08:40, devikas...@gmail.com wrote:

Does Jacoco provide code coverage for integration tests of APIs? That is, I have an instance of my application running locally and I have integration tests where I hit an api offered by my running application instance. In this scenario can I use Jacoco to get how many lines of my running application instance was covered when integration tests where ran?

--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/a17e87ee-1215-407c-bc1b-0c2d2b928fdd%40googlegroups.com.

Devika S

unread,
Sep 5, 2019, 2:26:10 AM9/5/19
to jac...@googlegroups.com
I configured javaagent for the application under test and dumped the coverage data locally from the tcpserver. The jacoco.exec for parent target gives the correct coverage. But for the child modules's target the coverage is given as 0. But in reality it is the child modules code that is covered, so it should be shown in both parent and child target's exec files right? Also since the parent does't have any classes i used report:aggregate to generate reports, that gives 0 coverage even for the parent target. The coverage report is generated from dumped exec files right. So how can that be 0 when exec files show non-zero coverage?


Marc Hoffmann

unread,
Sep 6, 2019, 8:41:03 AM9/6/19
to JaCoCo and EclEmma Users
I assume your application under tests consists of code from multiple modules. In this case execution data for all modules is collected in the exec file you retrieved via the tcpserver. Therefore you need to configure your build in a way, that this exec file is used for all modules. Either you copy the exec file to each module or you configure the dataFile properties of the report mojo to point to the central one.


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