Repaso
EspaƱol
TestingCoreTST-29

What does test coverage measure?

Options

  1. How many tests exist in the project in total
  2. The share of lines or branches run by the tests (Correct option)
  3. How fast the tests of the suite finally run
  4. How many bugs exist in the code of the project

Answer

The percentage of code lines (or branches) executed while the tests run

Why

A coverage tool (e.g. pytest --cov) watches which lines run during the tests and reports a percentage, plus which lines were never executed.

Those uncovered lines are code no test checks at all, good places to add tests.

High coverage does not guarantee good tests: it doesn't check that assertions are meaningful.

Remember

Coverage = % of code executed by tests.

Key terms

Practice this question in Repaso