Thursday, September 12, 2013

Run unit test once for both JUnit report and Emma report

Normally, I run unit tests to generate meta data (XML files) that is used to compose JUnit report (HTML). Here is the ant task for that:



And here's the task to create JUnit report HTML:

Then if I wish to create Emma report, I have to run unit tests the second time! (very time consuming and wasted). And here is the task to run unit test with instrumented code to generate Emma metadata (metadata.emma, coverage.ec):

Then here is how to generate Emma HTML report:

So the question is there's any way I can run unit tests just once and generate the metadata for both JUnit Report and Emma report? the answer is YES! here is the solution:

An Ant task to run unit test and generate both type of the metadata:

That's the trick. Hope you enjoy it!

No comments:

Post a Comment