Unit tests not showing up in sonar dashboard

Must-share information (formatted with Markdown):

  1. Which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Sonarqube Version8.9.0.43852 Developer Edition, SonarScanner 4.5.0.2216

  2. How is SonarQube deployed: zip, Docker, Helm
    Deployed with Docker

  3. what are you trying to achieve
    I’d like to show code coverage and unit-tests data in sonarqube project. Coverage is shown correctly, while unit-tests is not which is currently showing no unit test even though my application has tests

4.what have you tried so far to achieve this
Currently our sonar scanner is doing *-Dsonar.tests=${SQ_PROJECT_PATH}/src/test/ * to set the value for tests. But looks like the unit tests field on SonarQube dashboard for that app is still showing empty(attached the image below) where it shows no unit tests although the application has unit tests with >90% coverage.

Our project path for tests from repository root is app-name/src/test/java/outset/app_name. Which has the test folders for different packages in the repo. We tried changing the Dsonar.tests value to***${SQ_PROJECT_PATH}/src/test/java/outset/app-name//* .* And few other values but it does not seem to reflect the unit tests value on dashboard.

1 Like

I sort of given up on the unittests reports from Sonar (SonarCloud in our case). While the code coverage reports work well, the Test Results reports are very minimalistic and there is no historical information on the individual tests, adding very limited value.

That said for test reports to work you need the test report file(s) from whatever tool you run your tests with, it would probably be a junit style xml report, that the scanner then reads and parses.