Java Code Coverage for Eclipse
I didn't write it, but handy to have in your Eclipse is a complete code-coverage tool. Run your JUnit tests with this plug-in instead of straight JUnit, and it'll (try to) let you know where your tests don't hit.
It's pretty easy to install. Inside Eclipse, in the Help menu, go to the Software Updates and add a new location (this varies slightly on the version of Eclipse...it should be easy to figure out). Add the URL http://update.eclemma.org/ (and give it a name if Eclipse requires). Then do what is needed by the version of Eclipse to download and install (uh, make sure the box is checked, hit the install button). Eclipse will need to restart. Done.
It's also pretty easy to use. When a coverage report is desired, run the appropriate JUnit test by using the new Coverage menu or context menu: coverage as...JUnit test. JUnit will run as normal, and when done, a coverage report will be generated, and the source will be highlighted showing the test coverage.
The coverage report and highlighting, of course, are configurable. Personally, I turn off the coverage of my test source (or it's incorrectly shown as not being tested), and I turn off the highlighting of covered lines leaving only the uncovered lines highlighted. The first requires a trip to the larger coverage dialog (open the Coverage as... dialog from the coverage button or menu). The second is in the editor formatting under Windows Properties. Easy.
Now it's easy to tell what isn't tested with no noticeable difference in test run time.
Of course, Emma doesn't substitute a good code coverage check. It only shows that a line is executed during a JUnit test. It should always be the case that good (happy path) and bad (expected failures) tests are written. Most tested methods need three or four different tests for each branch of their logic, but that's a different topic.
Link: http://www.eclemma.org/