PHP sonar.php.tests.reportPath

I proceed with documentation: and pass that settings in file


When I run scanner I get:

INFO: Analyzing PHPUnit test report: execution-result.xml
INFO: Analyzing PHPUnit coverage report: coverage-result.xml

so I don’t have any warnings. But on main page of SonarQube I don’t have something similar like here:

on right bottom corner: Failures, Errors, Tests, Execution Time.
Did I doing something wrong, or I have to search those results something else place?

I used that PHPUnit documentation:

vendor/bin/phpunit --configuration ./phpunit.xml --coverage-clover=coverage-result.xml --log-junit=execution-result.xml

Hi @LocalHeroPro,

Thanks for getting in touch with us.
Which SonarQube version do you use?
The picture you use as an example here shows an older SonarQube version.


  • Community Edition
  • Version 8.4.2 (build 36762)
    brand new install.

So, how to fill up selected - by blue color - Unit Tests?

Hi @LocalHeroPro ,

I have tried to reconstruct the problem. Can you check if you have explicitly specified where your test files are located using sonar.tests? I admit that this is not additionally written in the documentation.

Here is my example file:



Thanks for replay.
In I have (among others):


So I don’t have last line from your replay. Can you explain what sonar.tests that means?

I’m trying to point sonar.tests to folder with tests by pointing to ./tests or tests, but after running some tests, nothing changed with count of Unit tests on Overall Code tab.
In bash log I have:

INFO: Analyzing PHPUnit test report: phpunit-execution-result.xml
INFO: Analyzing PHPUnit coverage report: phpunit-coverage-result.xml

So I guess, files are imported successfully and Sonar understood them ;]

As mentioned in the documentation, sonar.tests should be set with “comma-separated paths to directories containing test source files”. With this property, your test files can be imported in SonarQube and treated as such. In particular, they can be scanned by test-related rules. SonarQube only displays test execution results for files which are imported as test files.

If you still don’t see test execution results, try running the analysis with debug logs:

sonar-scanner -X

You may then see logs such as:

DEBUG: Following file is not located in the test folder specified in the Sonar configuration: /home/user1/myproject/tests/MyTest.php. The test results won't be reported in Sonar.

Nope, I can’t see anything interesting in that debug output:

// ...
23:00:24.439 INFO: 235/235 source files have been analyzed
23:00:24.440 INFO: Analyzing PHPUnit test report: phpunit-execution-result.xml
23:00:24.490 INFO: Analyzing PHPUnit coverage report: phpunit-coverage-result.xml
23:00:24.490 DEBUG: Parsing file: /var/www/cpt.local/html/phpunit-coverage-result.xml
23:00:24.554 INFO: Sensor PHP sensor [php] (done) | time=7089ms
23:00:24.554 INFO: Sensor Analyzer for "php.ini" files [php]
23:00:24.558 INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=4ms
// ...

I’m still looking what is going wrong.