Code Coverage

Code coverage measures used and unused code lines, statements, branches, etc. Depending on the programming language this is measured by instrumenting the code/binary and running the program, it’s test cases or simulating the code. In generate code coverage is a measure of test coverage. Unused code is not (yet) covered by tests.

The code coverage metric in percent is a ratio of used code versus all possibly usable code. A coverage of <100% indicates unused code. This can be dead code (unreachable) or untested code (⇒ needs more test cases).

Code Coverage Kinds

  • Coverage

    • Code coverage

      • statement coverage / line coverage

      • branch coverage

      • expression coverage

      • toggle coverage

      • state coverage (of state machines)

      • transition coverage (of state machines)

    • Functional coverage

    • Documentation coverage

    • Test coverage