Table of Contents

Sources:

  1. 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).

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

  1. Use mutation testing and code coverage together. Good code coverage does not equal good tests.
  2. 100% coverage does not guarantee good code quality, you do not have to chase after it.
  3. Use code coverage as a signal, not a goal.
  4. Launch coverage for all CI branches, not just main.
  5. Include coverage logs with pull requests.