What is code coverage?

Methodology that quantitatively measures how comprehensive a code base's tests are.

Increasing code coverage often increases stability and reduces bugs.

Formula:

  • Total number of non-syntax lines with tests / total number of non-syntax lines

When to care about code coverage?

  • Your product has users and those users might leave if they are affected by bugs

  • You are working with developers that aren't immediately trustworthy like contractors/interns

  • You are working on a very large code base with many testable components

Common mistake - too many tests for uncertain features

Last updated