Code coverage analysis

To better understand how Sonar works and to be in a position to better evaluate code coverage results, it is necessary to take a closer look at how code coverage tools analyze tests and calculate total coverage. The result of the coverage analysis process, although expressed as a single percentage number in Sonar, is based on many different coverage metrics.

Next, we will examine four fundamental coverage metrics used by all code coverage tools supported by Sonar:

  • Statement coverage
  • Branch coverage (also known as decision coverage)
  • Condition coverage
  • Path coverage

Statement coverage

Statement coverage is the most basic metric of the analysis process. It is the building block element for the rest of the metrics. The metric reports ...

Get Sonar Code Quality Testing Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.