Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge Multiple Test Runs into one Jacoco.exec file

In my project based on environment variable different set of integration tests are run. For e.g.

mvn test -Dconfig=a
mvn test -Dconfig=b

Running both lines gives full test coverage.

Now the problem is that each run will create a jacoco.exec file in the target folder, but the second run will override the first by deleting the target folder.

I want to use jacoco merge to combine the exec files but I am not sure how to go about it.

I can change the output directory to somewhere else other than target and merge but then how will I maintain version or do I have to add a line to delete the folder after merge is done.

Any help would be appreciated

like image 502
Spandan Thakur Avatar asked Oct 18 '22 19:10

Spandan Thakur


1 Answers

You can generate a separate exec as per your run/s. ( eg a.exec and b.exec ) post that you can use jacoco:merge plugin to merge your exec files to get one exec, which will have your complete coverage.

Reference for merging exec files via maven.

http://www.eclemma.org/jacoco/trunk/doc/merge-mojo.html

like image 140
Shivakumar ss Avatar answered Oct 21 '22 07:10

Shivakumar ss