Golang code coverage difficulties

Hello, welcome to the community!

I’ve seen some mention of using third-party tools to generate coverage reports, and then have sonar read those. Is that what I’m missing here?

Exactly, SonarQube is not computing coverage itself. You can find a small guide here, and the list of SonarQube properties here.

To sum up, you will have to:

  • Run go test -coverprofile=coverage.out before the analysis.
  • Set sonar.go.coverage.reportPaths to list paths of coverage report files.

Hope this helps.

Quentin

3 Likes