Main Page | See live article | Alphabetical index

Code coverage

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 distinct from most other testing methods because it looks at the code directly, rather than other measures such as software functions or object interfaces.

There are a number of different ways of measuring code coverage, the main ones being:

Usually the source code is instrumented and run through a series of regression tests. The resulting output is then analysed to see what areas of code have not been exercised, and the tests are updated to include these areas as necessary. Combined with other code coverage methods the aim is to develop a rigorous yet manageable set of regression tests.

Code coverage is ultimately expressed as a percentage, as in "We have tested 67% of the code". The meaning of this depends on what form(s) of code coverage have been used, as 67% path coverage is more comprehensive than 67% statement coverage.

See also: regression testing, static code analysis