# PHP sonar.php.tests.reportPath

**URL:** <https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132>\
**Category:** SonarQube Server / Community Build\
**Tags:** php, scanner\
**Created:** [November 7, 2020, 3:42pm UTC](https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132 "2020-11-07T15:42:32Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![LocalHeroPro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/localheropro/32/16639_2.png) [@LocalHeroPro](https://community.sonarsource.com/u/LocalHeroPro)\
**Post date:** [November 7, 2020, 3:42pm UTC](https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132/1 "2020-11-07T15:42:32Z")

</div>

I proceed with documentation: [https://docs.sonarqube.org/latest/analysis/coverage/](https://docs.sonarqube.org/latest/analysis/coverage/) and pass that settings in `sonar-project.properties` file

```auto
php.sonar.php.tests.reportPath=coverage-result.xml
php.sonar.php.coverage.reportPaths=execution-result.xml

```

When I run scanner I get:

```auto
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:

 ![](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/8/9/894b5781b0ac6672da6650c7af0ab70e7db57c68.png)  
on right bottom corner: Failures, Errors, Tests, Execution Time.  
Did I doing something wrong, or I have to search those results something else place?

EDIT:  
I used that PHPUnit documentation: [https://phpunit.readthedocs.io/en/9.3/textui.html](https://phpunit.readthedocs.io/en/9.3/textui.html)

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

```

---

<div class="post-metadata">

**Author:** ![Nils\_Werner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/nils_werner/32/14437_2.png) [@Nils\_Werner](https://community.sonarsource.com/u/Nils_Werner)\
**Post date:** [November 9, 2020, 8:51am UTC](https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132/2 "2020-11-09T08:51:52Z")

</div>

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.

Cheers,  
Nils

---

<div class="post-metadata">

**Author:** ![LocalHeroPro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/localheropro/32/16639_2.png) [@LocalHeroPro](https://community.sonarsource.com/u/LocalHeroPro)\
**Post date:** [November 10, 2020, 4:04pm UTC](https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132/3 "2020-11-10T16:04:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LocalHeroPro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/localheropro/32/16639_2.png) [@LocalHeroPro](https://community.sonarsource.com/u/LocalHeroPro)\
**Post date:** [December 21, 2020, 10:42pm UTC](https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132/4 "2020-12-21T22:42:17Z")

</div>

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

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/2/4/2481c729456b78ba8702ed745cda62863a0edb86.png)

---

<div class="post-metadata">

**Author:** ![Nils\_Werner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/nils_werner/32/14437_2.png) [@Nils\_Werner](https://community.sonarsource.com/u/Nils_Werner)\
**Post date:** [January 5, 2021, 4:22pm UTC](https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132/5 "2021-01-05T16:22:17Z")

</div>

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:

```auto
sonar.sources=src
sonar.php.tests.reportPath=execution-result.xml
sonar.php.coverage.reportPaths=coverage-result.xml
sonar.tests=tests

```

Cheers,  
Nils

---

<div class="post-metadata">

**Author:** ![LocalHeroPro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/localheropro/32/16639_2.png) [@LocalHeroPro](https://community.sonarsource.com/u/LocalHeroPro)\
**Post date:** [January 6, 2021, 8:28am UTC](https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132/6 "2021-01-06T08:28:56Z")

</div>

Hi,  
Thanks for replay.  
In `sonar=project.properties` I have (among others):

```auto
sonar.sources=./app
sonar.php.coverage.reportPaths=phpunit-coverage-result.xml
sonar.php.tests.reportPath=phpunit-execution-result.xml

```

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:

```bash
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 ;]

---

<div class="post-metadata">

**Author:** ![pynicolas](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/pynicolas/32/675_2.png) [@pynicolas](https://community.sonarsource.com/u/pynicolas)\
**Post date:** [January 12, 2021, 12:23pm UTC](https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132/7 "2021-01-12T12:23:25Z")

</div>

As mentioned in the [documentation](https://docs.sonarqube.org/latest/analysis/analysis-parameters/), `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](https://rules.sonarsource.com/php/tag/tests). 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](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/):

```auto
sonar-scanner -X

```

You may then see logs such as:

```auto
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.

```

---

<div class="post-metadata">

**Author:** ![LocalHeroPro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/localheropro/32/16639_2.png) [@LocalHeroPro](https://community.sonarsource.com/u/LocalHeroPro)\
**Post date:** [January 23, 2021, 10:17pm UTC](https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132/8 "2021-01-23T22:17:05Z")

</div>

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

```bash
// ...
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.

---

<div class="post-metadata">

**Author:** ![LocalHeroPro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/localheropro/32/16639_2.png) [@LocalHeroPro](https://community.sonarsource.com/u/LocalHeroPro)\
**Post date:** [December 24, 2021, 2:58pm UTC](https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132/9 "2021-12-24T14:58:48Z")

</div>

Right now with:

1. SonarQube 9.1 (build 47736)
2. SonarScanner 4.6.2.2472
3. PHP 8.0.14
4. PHPUnit 9.5.10  
XDEBUG\_MODE=coverage vendor/bin/phpunit --coverage-clover=phpunit-coverage-result.xml --log-junit=phpunit-execution-result.xml
5. File sonar-project.properties  
sonar.projectBaseDir=.  
sonar.sources=app  
sonar.tests=tests  
sonar.php.coverage.reportPaths=phpunit-coverage-result.xml  
sonar.php.tests.reportPath=phpunit-execution-result.xml

it’s works! I can see for example: execution time results in main branch, not in PR.

---

<div class="post-metadata">

**Author:** ![Nils\_Werner](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/nils_werner/32/14437_2.png) [@Nils\_Werner](https://community.sonarsource.com/u/Nils_Werner)\
**Post date:** [December 29, 2021, 8:40am UTC](https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132/10 "2021-12-29T08:40:43Z")

</div>

Great. Glad to hear it’s finally working. Thanks for sharing the update and your settings.  
This might help other users now as well.

Best,  
Nils

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [January 22, 2022, 4:49pm UTC](https://community.sonarsource.com/t/php-sonar-php-tests-reportpath/34132/11 "2022-01-22T16:49:13Z")

</div>

Closed on January 22, 2022, 4:49pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
