Unit testing with coverage reports from within Eclipse

The ever verbose (if you've seen his blog) Pjammy pointed me to this nifty Eclipse plugin called djUnit. Just right click on a JUnit test, select run with djUnit, and it runs the JUnit test with instrumentation to produce a code coverage report. Here's a screenshot. Not only that, it will mark the lines in the editor pane that don't have unit test coverage making it really easy to see where more thorough testing is needed.

I've gotten accustomed to seeing this type of report in Maven or Cruise Control, but I often wouldn't look at coverage until I was mostly done developing. That's a bad thing because code coverage becomes more of an afterthought or cleanup process and is therefor likely to be neglected. However, getting coverage reports from within Eclipse whenever I run my unit tests allows me to consider it in the midst of my TDD process resulting in much improved coverage.

This entry was posted in Java. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *