Monday, April 28, 2014

Code Coverage Tools For MyEclipse (And Doubtless For Eclipse Too)

At one of the technical sessions of the Idaho Technical Council last week, one speaker asked how many were using code coverage tools.  I was startled to see no hands.  (It was a big room, so I might have missed some behind a column.)

If you are only peripherally involved in software development, I should explain what a code coverage tool does.  It provides a way to find out what percentage of the code in your application is actually being executed, and shows with appropriate colors whether particular parts of your classes are being partially executed, completely executed, or not executed at all.  This is especially useful, in my experience, when writing automated unit tests.  Running code coverage tools in conjunction with automated unit tests tells you how thorough your unit tests are.  If only 15% of the code in the classes that are supposed to be tested are actually being executed, you need to improve your unit tests to be more thorough -- or figure out if you have code that cannot actually be executed.

I confess to being a bit surprised at the lack of code coverage tool use.  At a previous employer, I made extensive use of Visual Studio's code coverage tools to see how thoroughly my unit tests were testing various classes.  I assumed that there were code coverage tools for Eclipse and MyEclipse, but for various reasons, simply have not put much time into finding them.  There is one called EclEmma that I have installed in MyEclipse, and I believe works with the open source Eclipse as well, that works pretty well.

2 comments:

  1. For me, the most important use of code coverage tools is in running unit tests. It's easy to write hundreds or thousands of unit tests - it's much harder to ensure that the actually test all of the code.

    ReplyDelete
  2. If you asked for a show of hands of who had read Software Tools or The Mythical Man-Month, you'd probably get similar (and overlapping!) results.

    ReplyDelete