I am trying to get Netbeans code coverage checking feature working. I am working with PHP on a Windows XAMPP setup, and have setup PHPUnit which seems to work fine for running unit tests.
When I right-click my project and select "Code Coverage > Collect and Display Code Coverage", it displays a little bar at the bottom that says "0%" and has options to run tests and get a report.
I run the tests and check the report, yet it remains at 0%. If I check the report it says "No data - have you run your code yet?" I've tried rerunning the tests but it still does this. I've also tried just running the project, and also "debugging" the project to no avail.
Recent information on the topic is hard to come by, but judging by the PHPUnit documentation there could be an issue with Xdebug (I've enabled it, but no idea if it is working properly as I've not used it from within Netbeans before). Some old sources say that there are two php.ini's in Xampp (one for web, one for CLI), but I can't find a second one (guessing this has since changed).
I'm sure I am probably missing something fairly basic like an Xdebug setting or something... any help?
Here's the XDebug section from my php/php.ini file:
[XDebug]
zend_extension = "D:\xampp\php\ext\php_xdebug.dll"
;xdebug.profiler_append = 0
;xdebug.profiler_enable = 1
;xdebug.profiler_enable_trigger = 0
;xdebug.profiler_output_dir = "\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
;xdebug.trace_output_dir = "\xampp\tmp"
Is probably caused by this: http://forums.netbeans.org/topic47374.html. Apparently PHPUnit cannot deal with starting on c:\ and testing something on D:.
Therefore I run any tests I want coverage-reports on from the commandline using the --coverage-html /path/to/directory argument:
phpunit --bootstrap bootstrap.php --configuration phpunit.xml --coverage-html ./report ./unit
Where the last argument (./unit) means that this will test als tests in the unit/ subdirectory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With