Jacoco test coverage not shown

I have configured my Gitlab pipeline to run my unit tests. In Job artifacts, I can see the output file - jacoco.xml getting generated. I have configured the same path in SonarCloud project’s General Settings. But the coverage is still shown as 0%.
Please note that I am running this analysis on a feature branch.

Hi @abhishekonplan, welcome to the community forum

Could you please show us your pipeline definition file (without the private details of your project, if any)?
From the topic tags, I understand you use Maven, could you also show the logs produced during the execution of goal sonar:sonar?

So my Gitlab CICD pipeline’s Sonar job looks like this -

quality_scan:
stage: quality_scan
image:
name: maven:3.6.3-jdk-11
entrypoint: [""]
cache:
key: “${CI_JOB_NAME}”
paths:
- .sonar/cache
script:
- mvn verify sonar:sonar -Dsonar.qualitygate.wait=true -Dsonar.qualitygate.timeout=300 -P aws
allow_failure: true
except:
- master

And the logs for the job run are in attachment. Please not that I have provided selected logs.
sonar_output.txt (9.8 KB)

Hello @vishwa007,

Are you analyzing your main branch? It looks like you’re excluding your main branch from running an analysis

If you’re not analyzing a main branch that means code coverage will only be shown on the changed files. We automatically set-up the analysis so that it detects which merge request it is analyzing, the analysis will only show the code coverage of the changed files in the relevant merge request.

1 Like