Summary
In software engineering, 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. 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. Many different metrics can be used to calculate test coverage. Some of the most basic are the percentage of program subroutines and the percentage of program statements called during execution of the test suite. Test coverage was among the first methods invented for systematic software testing. The first published reference was by Miller and Maloney in Communications of the ACM, in 1963. To measure what percentage of code has been executed by a test suite, one or more coverage criteria are used. These are usually defined as rules or requirements, which a test suite must satisfy. There are a number of coverage criteria, but the main ones are: Function coverage - has each function (or subroutine) in the program been called? Statement coverage - has each statement in the program been executed? Edge coverage - has every edge in the control-flow graph been executed? 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.) Condition coverage - has each Boolean sub-expression evaluated both to true and false? (Also called predicate coverage.) For example, consider the following C function: int foo (int x, int y) { int z = 0; if ((x > 0) && (y > 0)) { z = x; } return z; } Assume this function is a part of some bigger program and this program was run with some test suite. Function coverage will be satisfied if, during this execution, the function foo was called at least once.
About this result
This page is automatically generated and may contain information that is not correct, complete, up-to-date, or relevant to your search query. The same applies to every other page on this website. Please make sure to verify the information with EPFL's official sources.