13

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.

Raja
  • 3,477
  • 12
  • 47
  • 89

2 Answers2

13

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
myselfmiqdad
  • 2,518
  • 2
  • 18
  • 33
Anurag Prashant
  • 995
  • 10
  • 31
10

It looks like you're mixing Linux paths and windows paths:

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

You're trying to write the coverage files to a folder called /tmp. On a Linux system this is a folder called tmp in the root of the drive. Change that to a Windows path (C:\tmp maybe?) and it should work.

yAnTar
  • 4,269
  • 9
  • 47
  • 73
Kryten
  • 15,230
  • 6
  • 45
  • 68