Wednesday, November 12, 2008

Code coverage

Code coverage is one of the basic metrics to measure code and test effectiveness. Usual definition is,

Code coverage is a measure used in software testing. It describes the degree to which the source code of a program has been tested. It is a form of testing that inspects the code directly and is therefore a form of white box testing. Currently, the use of code coverage is extended to the field of digital hardware, the contemporary design methodology of which relies on Hardware description languages (HDLs).

Code coverage techniques were amongst the first techniques invented for systematic software testing. The first published reference was by Miller and Maloney in Communications of the ACM in 1963.
 from Code coverage

It works in the following ways,

1. Instrumenting - Extracting the meta-data information from the byte code and saving that in file.
2. Monitoring - Monitoring the accessed code when the software is tested.
3. Report - Saving the collected data in to an report formation usually html.

Instrumenting may be done either onthefly or offline. More over eclipse plugins are available for the some tools.

A simple search will revel the existing code coverage tools for the different languages.

For Java, I've tried the following tools,


Both are open-source free tools. However, Emma can instrument the whole jar files. Cobertura only instruments the single class files at a time

The Dark Trio

Off topic:

The dark trio is follows,
1. Dark matter
2. Dark Energy
3. Dark Flow

How to measure these and do something with this?????????????????????

Find bugs using Findbugs

Findbugs is an statical code analysis tool developed by University of Maryland. Check it out here,

It has both ant and command line options to analyze the codes. However, most of commands won't work in windows. Windows users needs to get the Cygwin to get the commands working.

It offers the following,
1. You can write your own custom filters.
2. Filtering out results w.r.t class,jar,version etc
3. Suppressing the bugs which are false positives.

It is an alternative to the commercial tools which costs a bomb. Do check it out.


raja's shared items

There was an error in this gadget

My "Testing" Bundle