sebastianbergmann/phpunit-selenium — Issue #88: PHPUnit_Extensions_SeleniumTestCase::onNotSuccessfulTest method
Author: psemuu
Created: 2012-01-27 12:20:36+00:00
State: open

Consider the example.
We want to change the way screenshots are created (e.g. save them to a string for further processing, which is sometimes necessary when using Selenium Grid).
We override the method but because PHPUnit_Extensions_SeleniumTestCase::restoreSessionStateAfterFailedTest and PHPUnit_Extensions_SeleniumTestCase::stopSession are both private we have to copy their content into our method (not really good practice).
PHPUnit_Extensions_SeleniumTestCase::$sessionId is private so our plan fails - we have to skip this property.

So I propose one of the following:
- make PHPUnit_Extensions_SeleniumTestCase::restoreSessionStateAfterFailedTest and PHPUnit_Extensions_SeleniumTestCase::stopSession protected
- create a new method for handling screenshots (wrapped in if ($this->captureScreenshotOnFailure) { ... } in PHPUnit_Extensions_SeleniumTestCase::onNotSuccessfulTest)

There are some benefits from the second proposal:
- the ability to fully customize the handling of screenshots (we not always want to save it to a file right away)
- the possibility to use the new method on demand (make screenshots in crucial moments of our tests)
We would also avoid frequent changes to the onNotSuccessfulTest method in our *TestCase class, which are necessary whenever the method from the base class (PHPUnit_Extensions_SeleniumTestCase) changes and that happens often lately.