How do you know that your Unit tests cover all of your code? use a good Code Coverage tool

Unit Tests and Code Coverage


Unit Tests

In computer programming, unit testing is a procedure used to validate that individual units of source code are working properly. A unit is the smallest testable part of an application. In procedural programming a unit may be an individual program, function, procedure, etc., while in object-oriented programming, the smallest unit is a method; which may belong to a base/super class, abstract class or derived/child class.

Ideally, each test case is independent from the others; mock objects and test harnesses can be used to assist testing a module in isolation. Unit testing is typically done by developers and not by end-users. (Taken from WikiPedia)



Code Coverage

The Unit tests are a good measure of testing, but how much of the code is being covered? Did the unit test check all of the paths of the code flow?

These are the issues the Code coverage helps us solve.

The Code Coverage Tools run the Unit Tests we created and tell us explicitly how much code was really covered.

In order to better understand Code Coverage Usability I recommend the following article: In pursuit of code quality: Don't be fooled by the coverage report (Andrew Glover)


Java Code Coverage Tools

After some web research and software comparison, I came up with the following Software:

Clover

Cost: 1200$ | StandAlone + Eclipse Plugin. | 11/2007  

JCoverage

Cost: 99$ / Year. | Runs only as an Eclipse Plugin. | 11/2007  

Cobertura

Open Source. | No Plugin yet. | Jul-07  

Emma

Open Source. | No Plugin. | Jun-05  

ECL Emma

Open Source Only as an Eclipse Plugin | 11/2007  


The leading software (That conclusion is widely web spread and seems quite true) is CLOVER.

But after removing the commercial options (Clover + JCoverage) and the “Not updated in the last year” one (Emma), the choices are limited to:

  • ECL Emma.
  • Cobertura.


My Recommended choice is ECL Emma because it is so easy to install and runs smoothly from within Eclipse, ohh yeah it also won the EclipseCon 2007 Best Open Source Eclipse-based Developer tool.

Comments

Popular posts from this blog

Profiling Java @ 2019

Ant Explorer graphical Ant build tool

Start Working with AutoIT