Encyclopedia > Code coverage

  Article Content

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.)

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 develope 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



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Reformed churches

... Reformed movement, and the only one of the national Reformed churches to survive without division since the Reformation to the present time. The Hungarian Reformed Church ...

 
 
 
This page was created in 36 ms