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:
- Statement Coverage - Has each line of the source code been executed and tested?
- Condition Coverage - Has each evaluation point (such as a true/false decision) been executed and tested?
- Path Coverage - Has every possible route through a given part of the code been executed and tested? (Note that for a program that contains branches within a loop, it may be impossible to enumerate all possible routes through the code. See also the Halting Problem.)
These and other code coverage methods are often combined in practice to give a rigorous yet manageable set of 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.