Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integration Test Coverage for a webapp deployed on tomcat?

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?

like image 379
Kaleb Avatar asked Jul 21 '16 06:07

Kaleb


1 Answers

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:

  • Documentation for jacoco usage with maven
  • Example usage with maven

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

like image 56
G. Demecki Avatar answered Nov 14 '22 15:11

G. Demecki