phpunit -coverage-html report path

Raja picture Raja · Apr 1, 2014 · Viewed 28.5k times · Source

I have tried to execute phpunit with xdebug for code coverage as below,

C:\wamp\bin\php\php5.3.22>phpunit -coverage-html /tmp C:\<unittest file pat>\TestRetainer.php

and it is giving output as follows,

PHPUnit 3.7.32 by Sebastian Bergmann.

....

Time: 36 ms, Memory: 5.75Mb

OK (4 tests, 12 assertions)

C:\wamp\bin\php\php5.3.22>

But i am unable to find the html version of report file.

I had gone through this url http://phpunit.de/manual/current/en/phpunit-book.html#code-coverage-analysis. But i do not find any luck.

Please help me on this.

Answer

Anurag Prashant picture Anurag Prashant · Sep 25, 2018

For Linux, run command in the project root.

./vendor/bin/phpunit --coverage-html reports/

This will create a folder named reports in your project root.

For Windows:

C:\wamp\bin\php\php5.3.22>phpunit --coverage-html tmp C:\<unittest file pat>\TestRetainer.php

This will create a tmp folder inside php5.3.22, where your test report will generate.

Better if you keep reports inside your project root.

C:\wamp\htdocs\<project root> >phpunit --coverage-html tmp TestRetainer.php