Soarqube not picking up junit test files and coverage report

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    sonarqube-9.3.0.51899 on Mac macOS Big Sur
  • what are you trying to achieve
    Genrate junit code covarage
  • what have you tried so far to achieve this
    Here is the properties file
    sonar.projectKey=projectX
    sonar.projectName=projectX
    sonar.sourceEncoding=UTF-8
    sonar.sources=projectX/projectXX/biz/src/main/java
    sonar.login=477***
    sonar.java.binaries=**/target/classes
    sonar.tests=projectX/projectXX/biz/src/test/java

I run “sonar-scanner” in the project root directory and it generates the report but it shows 0% coverage and no unit test cases at all.

Thanks

Hey there.

When analyzing Java code, it’s important that you use a scaner like the Scanner for Maven , Scanner for Gradle , or Scanner for Ant . Why are you using the vanilla SonarScanner?

You will have to make sure that tests/code coverage reports have been generated before running the scanner, which means running a build. Community Guides like this one can help you:

https://community.sonarsource.com/t/coverage-test-data-importing-jacoco-coverage-report-in-xml-format/12151/11

1 Like