Does Sonarqube server has support for showing integration test code coverage for Go lang?

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Sonarqube version: 9.3
    INFO: Scanner configuration file: /opt/homebrew/Cellar/sonar-scanner/5.0.1.3006/libexec/conf/sonar-scanner.properties
    INFO: Project root configuration file: NONE
    INFO: SonarScanner 5.0.1.3006
    INFO: Java 21.0.1 Homebrew (64-bit)
    INFO: Mac OS X 13.4 aarch64

  • how is SonarQube deployed: zip, Docker, Helm
    Deployed via Docker

  • what are you trying to achieve
    Want the integration test coverage data to be reported and shown in sonarqube dashboard. The project is based on Golang.

  • what have you tried so far to achieve this
    We have followed golang doc: Coverage profiling support for integration tests - The Go Programming Language to instrument the build and ran integration tests against it to get the coverage data. Also, we are able to run the sonar scanner in our codebase which runs fine. However, we could not find any relevant flag(s) for us to upload the coverage data on to the sonarqube server. We have found only two flags in the sonar documentation:

sonar.go.coverage.reportPaths
sonar.go.tests.reportPaths

and we have passed the flag as:

-Dsonar.sonar.go.coverage.reportPaths=<path to the merged coverage binaries directory>

However, we found this in the scanner logs:

ERROR: Test report can't be loaded, file not found: '/Users/sporel/monitoring-app/./report.json', ignoring this file.
ERROR: Coverage report can't be loaded, report file not found, ignoring this file ./coverage.out.

Upon further exploration, both of the errors look related to the unit test code coverage.

We want to know the correct way to pass the integration test code coverage data to sonar server to be shown in the dashboard for Golang.

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hi,

Your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

9.3 → 9.9.3 → 10.3 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

In any case, SonarQube doesn’t distinguish between unit/integration test coverage – although you may see references to “unit test coverage” – if the scanner finds a valid report in the valid format , it will take it in.

So right now the big problem seems to be not being able to find the /coverage.out file you’ve specified. Are you sure it’s there? Can you run a cat ./coverage.out right before your SonarQube analysis?

That was the problem, placing the coverage.out file at the correct location fixed the issue. Thanks.

1 Like