What is Coverage? 0% Coverage

  • ALM used - Bitbucket Cloud
  • CI system used - Bitbucket Cloud
  • Scanner command used when applicable - BitBucket Pipeline (Automatic)
  • Languages of the repository - JS, XML, HTML & CSS

So I’ve just setup Sonar Cloud for 2 BitBucket Projects.

The below seems to work as intended:
Reliability - Bugs
Security - Vulnerabilities & Security Hotspots
Maintainability - Debt & Code Smells
Duplications - Duplications & Duplicated Blocks

But Coverage is at 0.0% for both the projects and most of the lines have a red indicator with a tool tip saying Not covered by tests.

What does this indicate?

From what I can infer, it is that SonarCloud is not testing these when it asses the above working measures, but I can see alot of code that is “Not covered by tests.” so I hope that is not the case.

If someone could clarify that’ll be great.

I know this is a very basic question but the documentation section was not of much help.

Thank you.

If you are writing unit tests, you can have code coverage information shown on SonarCloud.
There are few SonarCloud configs you can use to set it up. Here is an example config:

sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.testExecutionReportPaths=coverage/sonar-cloud-reporter.xml
sonar.tests=src
sonar.test.inclusions=**/*.spec.js

LCOV code coverage report is generated by jest and you can use jest-sonar-reporter to generate Sonar Cloud XML report.

If we are not using Jest i.e Unit Testing, I assume Coverage will not be a relevant metric.

And we should probably disable it as mentioned here Disable coverage test ??

It’s a very good practice to have unit tests, but yes, you can also disable it entirely if you want to.

Absolutely agree, thank you for your help!

1 Like