Number of Junit test missing in Sonar overall dashboard

Im using selfhosted Sonar * Enterprise Edition* Version 9.9.1 (build 69595)

I run sonar inside Azure Devops pipeline using Maven task but I cant see number of Junit test in Overall code tab.

Its a Java maven multi module project. I have pipeline with two templates. In first there is Maven build which also execute Junit test and compute coverage using Jacoco. I store these result to Artifact which I download inside second template where sonar scan is run with skipped tests option to true and I just set paths to those downloaded results. The coverage is working but the number of tests not. I checked the downloaded folder and there are correct result files of Junit test from surefire and failsafe(integration tests) plugins in xml.

Can somebody help?


- task: SonarQubePrepare@4
        displayName: 'sonarPrepare'
            SonarQube: 'SonarQube'
            scannerMode: 'Other'
            extraProperties: |
              sonar.projectName=${{ parameters.myName }}
              sonar.projectKey=${{ parameters.sonarProjectKey }}
            NODE_EXTRA_CA_CERTS: *******************************************

  - task: MavenAuthenticate@0
    displayName: 'Maven Authenticate'
      artifactsFeeds: '${{ parameters.mavenFeed }}'
  - task: Maven@3
    displayName: 'sonarAnalysis'
      mavenPomFile: 'pom.xml'
      goals: 'sonar:sonar -Dsonar.projectKey=${{ parameters.sonarProjectKey }}  -Dsonar.junit.reportPaths=$(System.DefaultWorkingDirectory)/${{ parameters.junitPath }} -Dsonar.projectVersion=${{ parameters.projectVersion }} -Dsonar.projectName=${{ parameters.myName }} -Dsonar.login=$(sonarKey)${{ parameters.sonarUrl }} -Dsonar.coverage.jacoco.xmlReportPaths=$(System.DefaultWorkingDirectory)/${{ parameters.pathToPublish }} -Dsonar.coverage.exclusions=${{ parameters.codeCoverageExclude }} sonar:sonar -Dmaven.test.skip=true -e -X'
      options: '$(JAVA_HOME)/lib/security/cacerts'
      javaHomeOption: 'JDKVersion'
      mavenVersionOption: 'Default'
      mavenAuthenticateFeed: false
      effectivePomSkip: false
      sonarQubeRunAnalysis: false

Hey there.

What do the logs say about the import of Junit test reports?

For example:

[**INFO**] Sensor SurefireSensor [java]
[**INFO**] parsing [/Users/colinmueller/Source/sonar-scanning-examples/sonarqube-scanner-maven/maven-basic/target/surefire-reports]
[**INFO**] Sensor SurefireSensor [java] (done) | time=1ms

Ohhh it reports this:

What could be the problem?

I would reckon since that you haven’t really provided the bytecode (just provided a value that won’t cause the analysis to fail), it’s not able to find all the necessary information.

You should actually point to the compiled binaries (see the documentation on Java analysis and bytecode).

Normally, this doesn’t have to be done manually, because the compilation and mvn sonar:sonar are happening in the same environment. I’m not sure what benefits you’re reaping by seperating them.