Skip to content

Instantly share code, notes, and snippets.

@serapheem
Created September 3, 2013 11:08
Show Gist options
  • Save serapheem/6422505 to your computer and use it in GitHub Desktop.
Save serapheem/6422505 to your computer and use it in GitHub Desktop.
PHPUnit - Failed test listener
<?php
namespace ClipKit\Test;
/**
* Base class for the selenium tests
*
* @author Serhiy Hlushko <s.hlushko@gmail.com>
*/
abstract class WebTestCase extends \PHPUnit_Framework_TestCase
{
public function onNotSuccessfulTest(\Exception $e)
{
if ($e instanceof \PHPUnit_Framework_ExpectationFailedException
&& getenv('SELENIUM_SCREENSHOT_CAPTURE')
) {
if ($fileUrl = $this->saveCurrentScreenshot()) {
echo PHP_EOL . PHP_EOL . 'ScreenshotUrl: ' . $fileUrl;
}
}
parent::onNotSuccessfulTest($e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment