

Basis path testing is for instance a method of achieving complete branch coverage without achieving complete path coverage. However, a general-purpose algorithm for identifying infeasible paths has been proven to be impossible (such an algorithm could be used to solve the halting problem). Many paths may also be infeasible, in that there is no input to the program under test that can cause that particular path to be executed. Int foo ( int x, int y ) paths within it loop constructs can result in an infinite number of paths.

Condition coverage – has each Boolean sub-expression evaluated both to true and false? (Also called predicate coverage.)įor example, consider the following C function:.Branch coverage – has each branch (also called the DD-path) of each control structure (such as in if and case statements) been executed? For example, given an if statement, have both the true and false branches been executed? (This is a subset of edge coverage.Edge coverage – has every edge in the control-flow graph been executed?.Statement coverage – has each statement in the program been executed?.Function coverage – has each function (or subroutine) in the program been called?.There are a number of coverage criteria, but the main ones are: These are usually defined as rules or requirements, which a test suite must satisfy. To measure what percentage of code has been executed by a test suite, one or more coverage criteria are used. The first published reference was by Miller and Maloney in Communications of the ACM, in 1963.

Test coverage was among the first methods invented for systematic software testing.

Some of the most basic are the percentage of program subroutines and the percentage of program statements called during execution of the test suite. Many different metrics can be used to calculate test coverage. A program with high test coverage has more of its source code executed during testing, which suggests it has a lower chance of containing undetected software bugs compared to a program with low test coverage. In computer science, code coverage is a percentage measure of the degree to which the source code of a program is executed when a particular test suite is run.
