I have a maven project which is compiled as WAR file. Then I have a separate test project that contains the integration test. The integration test project launches the web application via tomcat from the WAR files and then run tests.
The only coverage report that I have right now is for unit tests within the main project. Using JMockit-coverage and JUnit.
How can I get the code coverage of this web application which this integration test reaches?
You can use the excellent JaCoCo library. JaCoCo is basically a java agent, which you should start along with the JVM during your integration tests. Maven plugin: jacoco-maven-plugin
might be useful here.
Measured coverage will be recoreded inside jacoco.exec
file, by default.
A couple of useful links:
But when using maven-failsafe-plugin
and starting embedded tomcat from maven you may run into problems like this. Then probably the best way to go is usage of jacoco via ant
and maven-antrun-plugin
(working example). In spare time you may also take a look at this blog post.
Unfortunately, JaCoCo setup with maven can be time consuming.
Hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With