Code coverage is a measurement used to express which lines of code were executed by a test suite. We use three primary terms to describe each line executed.
- hit indicates that the source code was executed by the test suite.
- partial indicates that the source code was not fully executed by the test suite; there are remaining branches that were not executed.
- miss indicates that the source code was not executed by the test suite.
Coverage is the ratio of
hits / (sum of hit + partial + miss). A code base that has 5 lines executed by tests out of 12 total lines will receive a coverage ratio of
41% (rounding down).
Phrased simply, code coverage provides a visual measurement of what source code is being executed by a test suite. This information indicates to the software developer where they should write new tests in an effort to achieve higher coverage.
Testing source code helps to prevent bugs and syntax errors by executing each line with a known variable and cross-checking it with an expected output.
Code coverage tools incentivize developers to write tests and increase coverage. During the process of writing tests, the developer may discover new bugs or syntax issues in the source code that are important to resolve before distributing the application.
Codecov takes coverage to the next level. Unlike open source and paid products, Codecov focuses on integration and promoting healthy pull requests. Codecov delivers or "injects" coverage metrics directly into the modern workflow to promote more code coverage, especially in pull requests where new features and bug fixes commonly occur.
Updated about 2 years ago
For more information about code coverage: https://en.wikipedia.org/wiki/Code_coverage