Open chr0n1x opened 11 years ago
This is intended behavior, but it's missing a step. Selenium runs code in a different PHP process than the command line (an Apache process usually) and PHPUnit cannot measure coverage directly like for unit tests. So the coverage is dumped in the document root for each file, and then retrieved by Selenium2TestCase over HTTP to make a big merge and write a single coverage folder.
Ah, ok that explains it. Are there any plans to re-work / add to this functionality?
If not, could it be possible for that separate PHP process to write to a different doc root if I overwrite $coverageScriptUrl
?
So something like:
class thing extends PHPUnit_Extensions_Selenium2TestCase {
protected function setUp() {
$this->coverageScriptUrl = 'http://available.on.lan';
parent::setUp();
// ...
}
// ...
}
Or does $coverageScriptUrl
need to direct to the same location as phpunit_coverage.php
?
Finally, is this documented anywhere? I feel bad if I'm asking questions when I could just look them up myself :P
The coverage collection is documented (for both Selenium 1 and Selenium 2) here: http://phpunit.de/manual/current/en/selenium.html#selenium.seleniumtestcase.examples.WebTest3.php If you rewrite the coverage script and its siblings prepend and append, but maintain its output identical, it should continue to work.
I have everything working and I can get the code coverage report. Everything is being generated correctly.
Is there a way to direct all of the coverage output to a specific directory?
For example: in my application root (say,
/app/public
), I have thephpunit_coverage.php
script in a directory,clover
. When I run the command:The entire test runs, but all of the data files being generated by
phpunit_coverage.php
get written to/app/public
, not/app/public/clover
...all other coverage files (library files that are called directly in the tests) appear in/app/public/clover
Not sure if I'm doing anything wrong or if this is intended behavior.