4

I have a Java RESTful API. I use REST Assured for my functional tests on each endpoint.
Is there a way to get the code coverage for the classes/methods used behind the scene (controllers, services, DAOs/repositories, etc.) when REST Assured (or any similar tool) makes calls to the API? (I guess the API should be started with some agent or something that reports what happens until it is stopped?).

asked May 10, 2017 at 18:09
1
  • You could try using attribute tags above your methods and have Maven evaluate your code coverage. Commented May 10, 2017 at 18:11

1 Answer 1

1

I ended up using JaCoCo (Java agent and Maven plugin) with SonarQube

EDIT after Sikandar's comment:
In my case it's a Spring Boot app so when I run the jar file I add the option
-javaagent:/myapp/lib/jacoco.agent-0.7.9.jar=destfile=/myapp/coverage-reports/jacoco-at.exec
Reports are generated when the app is stopped. Then I configured SonarQube to use the file /myapp/coverage-reports/jacoco-at.exec for its analysis

answered May 23, 2017 at 19:27

2 Comments

Can you share the plugin details you added for getting the code coverage. I am trying to get the same using jmeter functional testing.
@Sikandar I added more details in my answer.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.