Different metrics for code coverage

Code coverage is a metric that measures the percentage of source code your tests execute. It helps you identify areas that may lack proper testing.1

Function coverage is a straightforward metric. It captures the percentage of functions in your code that your tests call.1

Line coverage measures the percentage of executable code lines that your test suite executed.1

Branch coverage measures the percentage of executed branches or decision points in the code, such as if statements or loops.1

Statement coverage measures the percentage of statements in your code that your tests execute. At first glance, you might wonder, “isn’t this the same as line coverage?” Indeed, statement coverage is similar to line coverage but takes into account single lines of code that contain multiple statements.1

Sources

Footnotes

  1. https://web.dev/ta-code-coverage/ ↩ ↩2 ↩3 ↩4 ↩5