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.
IDEs and coverage collecting agents report coverage differently. Codecov does not conform to any standard, nor do we make any attempt to express our metrics in the exact same way the IDE, or coverage reports, may express coverage.
Codecov's coverage ratio is:
hits / (hits + misses + partials).
Codecov is a reporting tool that is intended to process any coverage report format into a format that is standard across Codecov.
You may change the configuration of how Codecov processes reports and expresses coverage information. Please review our Codecov Yaml to learn about the configuration options.