giorgiosironi / phpunit-selenium

Selenium RC integration for PHPUnit
http://www.phpunit.de/
Other
602 stars 271 forks source link

Tests failing when code coverage is enabled #395

Closed linaori closed 7 years ago

linaori commented 7 years ago

All of my selenium test cases are failing when coverage is enabled:

PHPUnit_Extensions_Selenium2TestCase_WebDriverException: <unknown>: Failed to set the 
'cookie' property on 'Document': Cookies are disabled inside 'data:' URLs.

I am unable to disable this feature and I don't want to turn of my coverage, because for my other tests it's still important. To be honest, I'm not even remotely interested by coverage of my functional tests, because the applications I'm testing are not even in the same repository.

How can I turn this off without hacking?

giorgiosironi commented 7 years ago

This behavior is governed by https://github.com/giorgiosironi/phpunit-selenium/blob/master/PHPUnit/Extensions/Selenium2TestCase.php#L312 so you can open a PR to make it overridable as a protected property instead of private, which is only set from the PHPUnit configuration if it is not already set by the child test case.

Another easier solution is to use PHPUnit's @group or --filter to run two separate PHPUnit processes sequentially, so that you can turn off/on coverage more selectively.

Finally, this code doesn't normally fail as it appears here the browser is loading a data:... URL like an image, in its main window. Is that expected? A browser does not provide much functionality to load this with respect to simply making an headless HTTP request directly.

linaori commented 7 years ago

This behavior is governed by https://github.com/giorgiosironi/phpunit-selenium/blob/master/PHPUnit/Extensions/Selenium2TestCase.php#L312 so you can open a PR to make it overridable as a protected property instead of private, which is only set from the PHPUnit configuration if it is not already set by the child test case.

That's what I've tried, did't work sadly.

Another easier solution is to use PHPUnit's @group or --filter to run two separate PHPUnit processes sequentially, so that you can turn off/on coverage more selectively.

No, that's not going to work. The coverage should only exclude specific tests, regardless of group. If everything is ran, it should still be excluded as that's where it also fails.

Finally, this code doesn't normally fail as it appears here the browser is loading a data:... URL like an image, in its main window. Is that expected? A browser does not provide much functionality to load this with respect to simply making an headless HTTP request directly.

Not sure, running it headless. I'm not too familiar with the API, this is just what I get.

During startTestSuite I run the following code, but that's about all I do regarding configuration:

    $test->setBrowser('chrome');
    $test->setBrowserUrl($application->getUrl());
    $test->setSeleniumServerRequestsTimeout(15);
egeloen commented 7 years ago

@giorgiosironi @iltar You can close this issue. It has been fixed in the referenced PR :)