Home > other >  How to get test coverage for the REST API endpoints?
How to get test coverage for the REST API endpoints?

Time:09-22

My project - Java, Spring boot, Maven, Junit, Jacoco

I am starting the spring application context and running the integration tests against REST API endpoints. And I want to see the report with integration test coverage, like this:

List of endpoints (4):

  1. api/status --->>> not covered

  2. api/users --->>> not covered

  3. api/countries --->>> covered

  4. api/offices --->>> covered

CodePudding user response:

As far as I know, that cannot be done. JaCoCo does not see endpoints, JaCoCo sees code and methods.

CodePudding user response:

Running the test using JUnit will automatically set in motion the JaCoCo agent. It will create a coverage report in binary format in the target directory, target/jacoco.exec.

In order to interpret the output you can use plugins like Sonar Qube.

The conventional way is to use the jacoco:report goal in order to generate readable code coverage reports in formats like HTML, CSV, and XML.

  • Related