Skip to main content

TagUnit and code coverage with Clover

Posted by simongbrown on March 24, 2004 at 1:25 PM PST

I've been using Clover for a few months now, but only in the context of my standalone JUnit tests and mainly from within IntelliJ IDEA. Having played with the Clover/Ant integration over the past few days, as with the IDEA integration, I can safely say that getting coverage reports for your unit tests is remarkably easy. Although I've known that it was possible, I've never tried running the instrumented code (that Clover generates) inside a J2EE container. So, to satisfy my curiosity, after a quick bit of Ant hacking the instrumented code was running inside Tomcat and updating the coverage database while my TagUnit tests were running.

It's really simple to do too - just build the instrumented classes into your normal JARs and deploy as usual. The only gotcha is that the coverage data doesn't always get written to disk until the JVM shuts down. Of course, you can fix this with the flushinterval attribute of the <clover-setup> Ant task.

Here's a screenshot of the coverage report for some JSP custom tags that are part of a TagUnit test suite...

Code coverage results for some TagUnit tests

...looks like I still have more work to do. ;-)

Related Topics >>