Example #1
0
 /**
  * This method is called when a test method did not execute successfully.
  *
  * @param Exception $e
  * @since Method available since Release 3.4.0
  */
 protected function onNotSuccessfulTest(Exception $e)
 {
     if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
         $buffer = 'Current URL: ' . $this->drivers[0]->getLocation() . "\n";
         $message = $e->getCustomMessage();
         if ($this->captureScreenshotOnFailure && !empty($this->screenshotPath) && !empty($this->screenshotUrl)) {
             $this->drivers[0]->captureEntirePageScreenshot($this->screenshotPath . DIRECTORY_SEPARATOR . $this->testId . '.png');
             $buffer .= 'Screenshot: ' . $this->screenshotUrl . '/' . $this->testId . ".png\n";
         }
     }
     try {
         $this->stop();
     } catch (RuntimeException $e) {
     }
     if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
         if (!empty($message)) {
             $buffer .= "\n" . $message;
         }
         $e->setCustomMessage($buffer);
     }
     throw $e;
 }