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?).
解决方案
You can also use a service like Sealights as this is the problem we solve (I work there) - get code coverage beyond unit tests, meaning that all of your Functional, Selenium, Integration, Performance testing are reported into a single dashboard.
Note that the solution you have used (JaCoCo) is OK but it has drawbacks such as:
Is it only for Java.
You have to collect the coverage from multiple machines and unify it (assuming that you have micro-services or many servers) in order to get the final report.
The coverage is available only when the process is going down so if you have very long tests, it may take you hours till you'll have your initial info.
You can't see the coverage of your backend & frontend code in a single location.
Basically in Sealights we solve all of those problems, help you to focus your tests in areas in the code which have changed, provide status reports will show you how your team is doing including tips on how to optimize your tests and some other cool features.
Last but not least, currently we support Java, NodeJS, Browser Based Tests (ie, Selenium), .NET and Python.
Happy programming ;-)