API run code coverage.

18 views
Skip to first unread message

Kush Mishra

unread,
May 6, 2024, 2:28:42 AMMay 6
to JaCoCo and EclEmma Users
Hi 

I am exploring tools capable of capturing the code coverage against the run of an API.
There would be a Java application and I would hit the endpoints via postman. I am interested in knowing the code coverage of this hit. Is this possible using Jacoco ? Till now what I have explored about it is all related to unit test cases.
I am planning to build a report UI on top of this to monitor code coverage against APIs.

Best regards
Kush

Marc Hoffmann

unread,
May 6, 2024, 8:42:57 AMMay 6
to JaCoCo and EclEmma Users
Hi Kush,

sure JaCoCo can collect execution data for any Java application.

To collect coverage data of a specific “hit” you have to execute the processing in isolation. As JaCoCo collects execution data of all executed code, you can not run this test while the server serves other requests too.

The steps are as always:

1) Run the server with the JaCoCo agent attached
2) Execute some test (e.g. exercise the endpoints)
3) Shut down the server properly to get the execution data file
4) Create coverage report

Alternatively JaCoCo agent supports a remote control protocol: This allows to collect and reset execution data without shutdown. So you can select separate coverage data for each request.

I am planning to build a report UI on top of this to monitor code coverage against APIs.

I think this is perfectly possible with the JaCoCo APIs.


Regards,
-marc


Disclaimer: This email and its attachments, if any, is intended for the recipient(s) specified in the email only and may have proprietary, privileged and classified information. If you are not the intended recipient, do not distribute, disseminate or copy this email. Please inform the sender immediately, and delete this email.

--
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/ee40671e-98f2-4369-808d-d761c5f924b1n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages