code_coverage
Table of Contents
Sources:
- Software Testing course at ITMO university by Kochubeev Nikolay Sergeevich
Code coverage
Code coverage is a metric for software testing that shows what percentage of the source code is tested.
Criteria
Percentage is calculated as (items tested/items found).
- function coverage;
- statement coverage;
- branches coverage;
- condition coverage;
- line coverage.
Using code coverage in CI/CD
Why use code coverage in CI/CD at all? It is an automatic test quality control, which is quite fast (compared to mutation testing). It also makes the process more transparent for the team, and it is an automatic way to drop the build if the code coverage is too low.
Best practices
- Use mutation testing and code coverage together. Good code coverage does not equal good tests.
- 100% coverage does not guarantee good code quality, you do not have to chase after it.
- Use code coverage as a signal, not a goal.
- Launch coverage for all CI branches, not just main.
- Include coverage logs with pull requests.
code_coverage.txt · Last modified: by plida
