Nothing too out of the ordinary, just a dumb hello world with a couple simple and easily tested functions.
I’ve tried so many different settings in my sonar-project.properties (like the sane default suggested here https://docs.sonarqube.org/latest/analysis/languages/go/ which should work just fine), but it always shows that we have 0.0% code coverage.
I’ve also tried manually specifying sonar.test.inclusions=cmd/sonartest/main_test.go just to see if I could reduce the number of allegedly uncovered lines, and I see no change.
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?
@Quentin when I send those coverage reports to Sonar I get an error:
**16:26:26** INFO: Load coverage report from '/var/lib/jenkins/workspace/P-237288-code-coverage-sonarqube/tests/coverage/api.cov' **16:26:26** ERROR: Error parsing coverage info for file /var/lib/jenkins/workspace/P-237288-code-coverage-sonarqube/tests/coverage/api.cov: Invalid go coverage, expect 'mode:' on the first line. **16:26:26** INFO: Load coverage report from '/var/lib/jenkins/workspace/P-237288-code-coverage-sonarqube/tests/coverage/backend.cov' **16:26:26** ERROR: Error parsing coverage info for file /var/lib/jenkins/workspace/P-237288-code-coverage-sonarqube/tests/coverage/backend.cov: Invalid go coverage, expect 'mode:' on the first line.
go test ./... -race -coverprofile cover.out && go tool cover -func cover.out -o /go/src/foo/cistern/coverage/backend.cov (this is running in a container with a mounted volume)
In order to have code coverage, you will have to use the traditional analysis, you can have a look at this part of the documentation as a starting point.
I have the same problem.In a branch it shows only the new lines and not the whole code plus everithing besides coverage estimated after merge is 0%.Did you solve it in anyway?