SonarCloud recognizing tests, but not their coverage


If the JaCoCo coverage tool was not executed while you were building your project, there is no chance that SonarCloud can get your coverage data.

Can you share the command you used to trigger the build and scan of this project?


I’m using the default Maven GitLab CI/CD command. I’ll post .gitlab-ci.yml’s contents below:

  SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache
  GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task
  image: maven:3.6.3-jdk-11
    key: "${CI_JOB_NAME}"
      - .sonar/cache
    - mvn verify sonar:sonar -Dsonar.projectKey=CATboardBETA_xtrmthjava
    - merge_requests
    - master
    - develop

Hi William,

The basic idea is that SonarCloud does not perform coverage analysis itself. It relies on you setting up a coverage tool (like Jacoco, for Java), having that tool run on each build, before the SC analysis is performed.

SC is then configured to pick up that coverage report on each analysis, process it and display the data as partof its results.

Have a look here for some guidance: [Coverage & Test Data] Importing JaCoCo coverage report in XML format

Hello! I’ve been working to set up Jacoco all day, but I simply can’t figure it out. Can you contact me on discord (CATboardBETA#0080) where we could figure this out? Thank you, appreciate it.

Jacoco setup is not our area of expertise. There are a number of tutorials online. For example a quick Google search on my part found this: Maven - JaCoCo code coverage example -

Once you successfully produce a coverage report on each build, you simply have to configure the sonarscanner to pick up that report by specifying the path to the report in the analysis parameter sonar.coverage.jacoco.xmlReportPaths. See the docs here:

The essential point is to set up your build pipeline so that the coverage report is always produced before the sonar scanner analysis runs.