Exemplo n.º 1
0
 /**
  * After Scenario hook
  *
  * @param ScenarioEvent $event
  */
 public function afterScenario(ScenarioEvent $event)
 {
     $scenario = $event->getScenario();
     $feature = $scenario->getFeature();
     $url = $feature->getFile();
     $issue = $this->jiraService->getIssue($url);
     if ($issue) {
         $this->postComment($issue, $event->getResult(), $scenario->getTitle());
         $this->updateIssue($issue, $event->getResult());
     }
 }
Exemplo n.º 2
0
 /**
  * Listens to "scenario.after" event.
  *
  * @param   Behat\Behat\Event\ScenarioEvent     $event
  */
 public function afterScenario(ScenarioEvent $event)
 {
     if (StepEvent::FAILED === $event->getResult()) {
         $scenario = $event->getScenario();
         $this->writeln($scenario->getFile() . ':' . $scenario->getLine());
     }
 }
 function let(CodeCoverageSession $coverageSession, Session $session, Filesystem $filesystem, StepEvent $stepEvent, StepNode $stepNode, ScenarioEvent $scenarioEvent, ScenarioNode $scenarioNode)
 {
     $stepEvent->getStep()->willReturn($stepNode);
     $stepEvent->getResult()->willReturn(StepEvent::PASSED);
     $scenarioEvent->getScenario()->willReturn($scenarioNode);
     $scenarioEvent->getResult()->willReturn(StepEvent::PASSED);
     $this->beConstructedWith($coverageSession, $session, $filesystem);
 }
Exemplo n.º 4
0
 /**
  * @AfterScenario
  */
 public function printLastResponseOnError(ScenarioEvent $scenarioEvent)
 {
     if ($scenarioEvent->getResult() != 0) {
         // avoid the error if we're using Goutte and there has been no request yet
         if ($this->getSession()->getDriver() instanceof GoutteDriver && !$this->getSession()->getDriver()->getClient()->getRequest()) {
             return;
         }
         // uncomment to better scenario debug
         //$this->getSubcontext('mink')->printLastResponse();
     }
 }
 /**
  * @AfterScenario
  */
 public function tearDown(ScenarioEvent $event)
 {
     if (empty($this->parameters['instances'])) {
         return;
         // Local Setup doesn't need to transmit data to testingbot
     }
     $url = $this->getSession()->getCurrentUrl();
     $parts = explode("/", $url);
     $sessionID = $parts[sizeof($parts) - 1];
     $data = array('session_id' => $sessionID, 'client_key' => $this->parameters['key'], 'client_secret' => $this->parameters['secret'], 'success' => $event->getResult() === 0 ? true : false, 'name' => $event->getScenario()->getTitle());
     $this->apiCall($data);
 }
Exemplo n.º 6
0
 public function after(ScenarioEvent $event)
 {
     if ($event->getResult() !== StepEvent::FAILED || !defined('TEMP_DIR')) {
         return;
     }
     echo "\nDumping error logs... \n";
     foreach (array_merge(glob(TEMP_DIR . '/error.log'), glob(TEMP_DIR . '/info.log'), glob(TEMP_DIR . '/critical.log')) as $logfile) {
         readfile($logfile);
         echo "\n";
     }
     if (!Debugger::$browser) {
         return;
     }
     echo "\nOpening bluescreens... \n";
     foreach (glob(TEMP_DIR . '/exception-*.html') as $file) {
         exec(Debugger::$browser . ' ' . escapeshellarg($file));
     }
 }
 /**
  * Close modal dialog if test scenario fails on CMS page
  *
  * @AfterScenario
  */
 public function closeModalDialog(ScenarioEvent $event)
 {
     try {
         // Only for failed tests on CMS page
         if (4 === $event->getResult()) {
             $cmsElement = $this->getSession()->getPage()->find('css', '.cms');
             if ($cmsElement) {
                 try {
                     // Navigate away triggered by reloading the page
                     $this->getSession()->reload();
                     $this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
                 } catch (\WebDriver\Exception $e) {
                     // no-op, alert might not be present
                 }
             }
         }
     } catch (\WebDriver\Exception $e) {
         $this->logException($e);
     }
 }
Exemplo n.º 8
0
 /**
  * Return recorded events
  *
  * @return array
  */
 public function getEvents()
 {
     $events = $this->getEventRecorder()->rip();
     foreach ($events as $key => $eventTurple) {
         list($name, $event) = $eventTurple;
         if ($event instanceof StepEvent) {
             $event = new StepEvent($event->getStep(), $event->getLogicalParent(), new NullContext(), $event->getResult(), null, $event->getException() ? new WorkerException($event->getException()->getMessage()) : null, $event->getSnippet());
         }
         if ($event instanceof OutlineExampleEvent) {
             $event = new OutlineExampleEvent($event->getOutline(), $event->getIteration(), new NullContext(), $event->getResult(), $event->isSkipped());
         }
         if ($event instanceof ScenarioEvent) {
             $event = new ScenarioEvent($event->getScenario(), new NullContext(), $event->getResult(), $event->isSkipped());
         }
         $event->setDispatcher(new NullEventDispatcher());
         $events[$key] = array($name, $event);
     }
     return $events;
 }
Exemplo n.º 9
0
 /**
  * Listens to "scenario.after" event.
  *
  * @param   Behat\Behat\Event\ScenarioEvent $event
  *
  * @uses    collectScenarioResult()
  */
 public function afterScenario(ScenarioEvent $event)
 {
     $this->collectScenarioResult($event->getResult());
 }
Exemplo n.º 10
0
 /**
  * @AfterScenario
  * @param ScenarioEvent $event
  */
 public function stopCapture(ScenarioEvent $event)
 {
     if ($this->captureProcess !== NULL) {
         $tmpFilePath = $this->getTmpFilename();
         $failedCapturePath = rtrim($this->reportsPath, '/') . '/' . strtr($event->getScenario()->getTitle(), array(' ' => '_', '.' => '_')) . '.mp4';
         $this->captureProcess->stop(3, SIGTERM);
         if (file_exists($tmpFilePath)) {
             if ($event->getResult() === StepEvent::FAILED) {
                 if (!is_dir(dirname($failedCapturePath))) {
                     mkdir(dirname($failedCapturePath), 0777, TRUE);
                 }
                 if (file_exists($failedCapturePath)) {
                     unlink($failedCapturePath);
                 }
                 rename($tmpFilePath, $failedCapturePath);
             } else {
                 unlink($tmpFilePath);
             }
         }
     }
     $this->captureProcess = NULL;
 }
Exemplo n.º 11
0
 /**
  * @param ScenarioEvent|OutlineExampleEvent $event
  */
 public function afterScenario($event)
 {
     if (!$this->enabled) {
         return;
     }
     $this->currentReport['result'] = $event->getResult();
     $this->report[] = $this->currentReport;
 }