Selenium Code Coverage is blank

I was able to install Selenium and able to install PHPUnit.

When I run unit tests, it writes a great looking report of my code coverage from the standpoint of my unit tests.

But when I run the functional tests, it writes files to my coverage directory that says 0/0 lines passed 100%

I have been up and down trying to figure out how to get the coverage to work for Selenium / functional tests.



I know I’m resurrecting a very old question, but I found that by following the instructions in this forum, I got 85% of the way there (I haven’t posted enough to be allowed to include links, so search the forum for “installation guideline code coverage report” and follow the first link).

I ended up moving the prepend.php and append.php into my project’s document root. I also found that the temporary file location made a difference - I originally was trying to save them to /tmp/ and PHP was silently failing. When I changed $GLOBALS[‘PHPUNIT_COVERAGE_DATA_DIRECTORY’] to myroot/protected/runtime/tmp and did a chmod 777 on that directory, it started working.

One thing that might frustrate you a bit is that code run through Ajax does not get flagged as being covered. This appears to be a known problem with Selenium. Google "github sebastianbergmann phpunit-selenium issues" and track down closed issue #22 for more information.