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,

Emma
Cobertura

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

ShareThis

raja's shared items

There was an error in this gadget

My "Testing" Bundle