Glossary · Automation software engineering and architecture
Code coverage
Also known as: Structural coverage
German: Codeabdeckung
In software testing, code coverage is a measure of which parts of the source code have been executed by a set of tests, expressed for example as the percentage of statements, branches or conditions exercised.
- Software engineering
In one sentence
Code coverage measures which statements, branches or conditions of the source code a test suite has executed.
Example
The unit tests of a conveyor control library reach full statement coverage, but branch coverage shows that the jam-detection timeout path has never been tested.
How it applies
- Engineering: Coverage tools instrument the code and record what was executed during tests. Common metrics are statement coverage, branch coverage and modified condition/decision coverage (MC/DC), in increasing order of rigor.
- Quality: Coverage reveals untested code; it does not show that the tested code is correct. High coverage with weak assertions gives false confidence. Functional safety standards such as IEC 61508 recommend structural coverage measures depending on the safety integrity level.
- Documentation: Test reports should state which coverage metric was measured, on which software version and with which tool, and justify any uncovered code. Coverage reports are part of the verification evidence in safety and regulated projects.
Code coverage vs. test coverage
Code coverage is structural: it measures execution of code. Test coverage is broader and often refers to how well tests cover requirements or risks. A project can have full code coverage and still miss requirements that were never implemented.