Interview Security & DevSecOps

How does SonarQube measure code coverage, and does it run your tests? [Basic]

Answer

SonarQube measures code coverage by importing coverage reports generated by test tools. It does not normally run the tests itself; the CI pipeline runs tests and passes reports such as JaCoCo, LCOV, coverage.py, or Cobertura into SonarQube.

Technical explanation

Coverage reflects which lines or branches were exercised by tests, depending on the language and report format.

A missing or misconfigured report can show zero coverage even if tests ran successfully.

Coverage should be used with judgment because high coverage does not prove strong assertions or complete security testing.

Hands-on example

Java example: run mvn test jacoco:report, then run sonar-scanner or mvn sonar:sonar with sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml. The PR gate checks new-code coverage based on that imported report.

Preparing for an interview?

Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.

More Security & DevSecOps interview questions

← All Security & DevSecOps questions