Spandan Thakur
Spandan Thakur

Reputation: 368

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

Upvotes: 7

Views: 5825

Answers (1)

Shivakumar ss
Shivakumar ss

Reputation: 663

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

Upvotes: 4

Related Questions