SonarQube shows 0% coverage even though tests run. How do you fix it?

IntermediateTroubleshootingSonarQube
Answer

Short answer

SonarQube doesn't run tests — it only imports a coverage report. 0% means the report wasn't generated, was in the wrong format, or the scanner wasn't told the path. Generate the report before the scan and set the correct property.

Checklist by language

Language Report Property
Java (Maven) JaCoCo XML target/site/jacoco/jacoco.xml sonar.coverage.jacoco.xmlReportPaths (auto-detected at default path)
JS/TS coverage/lcov.info (jest --coverage) sonar.javascript.lcov.reportPaths
Python coverage.xml (pytest --cov --cov-report=xml) sonar.python.coverage.reportPaths
.NET OpenCover / Cobertura (coverlet) sonar.cs.opencover.reportsPaths
Go coverage.out sonar.go.coverage.reportPaths

Other causes

  • Scan ran before tests, or in a different job/container where the file doesn't exist (pass it as an artifact).
  • Path mismatch — the report has absolute paths from another container (common in Docker/monorepos); fix with relative paths or sonar.projectBaseDir.
  • Files excluded by sonar.coverage.exclusions.
  • The scanner log shows a warning like "No coverage report can be found" — read it.

What to say in the interview

"SonarQube only imports coverage, so I make sure tests produce the report before the scan, in the same workspace, and set the right report-path property for the language. Then I check the scanner log for 'report not found' or path-mismatch warnings."

All Security Tools questions Roadmap: SonarQube — code quality & SAST

More on SonarQube