/** * 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); }
/** * 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()); } }
/** * @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); }
/** * @BeforeScenario */ public function beforeScenario(ScenarioEvent $event) { if (in_array('javascript', $event->getScenario()->getTags())) { $client = new Client(); $client->request('GET', $this->getUrl('test/reinstall')); $status = $client->getResponse()->getStatus(); $content = $client->getResponse()->getContent(); } else { $this->visit('test/reinstall'); $status = $this->getSession()->getStatusCode(); $content = $this->getSession()->getPage()->getContent(); } $this->checkForResponseError($status, $content, 'Unable to init platform'); }
/** * Configures default Mink session before each scenario. * Configuration is based on provided scenario tags: * * `@javascript` tagged scenarios will get `javascript_session` as default session * `@mink:CUSTOM_NAME tagged scenarios will get `CUSTOM_NAME` as default session * Other scenarios get `default_session` as default session * * `@insulated` tag will cause Mink to stop current sessions before scenario * instead of just soft-resetting them * * @param ScenarioEvent|OutlineExampleEvent $event */ public function prepareDefaultMinkSession($event) { $scenario = $event instanceof ScenarioEvent ? $event->getScenario() : $event->getOutline(); $session = $this->parameters['default_session']; foreach ($scenario->getTags() as $tag) { if ('javascript' === $tag) { $session = $this->parameters['javascript_session']; } elseif (preg_match('/^mink\\:(.+)/', $tag, $matches)) { $session = $matches[1]; } } if ($scenario->hasTag('insulated')) { $this->mink->stopSessions(); } else { $this->mink->resetSessions(); } $this->mink->setDefaultSessionName($session); }
/** * Listens to "scenario.before" event. * * @param ScenarioEvent $event * * @uses printScenarioHeader() */ public function beforeScenario(ScenarioEvent $event) { $scenario = $event->getScenario(); $this->currentScenario = $this->createScenario($scenario, 'scenario'); }
/** * Configures default Drupal driver to use before each scenario or outline. * * `@api` tagged scenarios will get the `api_driver` as the default driver. * * Other scenarios get the `default_driver` as the default driver. * * @param ScenarioEvent|OutlineEvent $event */ public function prepareDefaultDrupalDriver($event) { $scenario = $event instanceof ScenarioEvent ? $event->getScenario() : $event->getOutline(); // Set the default driver. $driver = $this->parameters['default_driver']; foreach ($scenario->getTags() as $tag) { if (isset($this->parameters[$tag . '_driver'])) { $driver = $this->parameters[$tag . '_driver']; } } $this->drupal->setDefaultDriverName($driver); }
/** * 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; }
function let(ScenarioEvent $event, ScenarioNode $node) { $event->getScenario()->willReturn($node); $this->beConstructedWith($event); }
/** * Listens to "scenario.after" event. * * @param ScenarioEvent $event * * @uses printScenarioFooter() */ public function afterScenario(ScenarioEvent $event) { $this->printScenarioFooter($event->getScenario()); }
private function buildScenarioEvent(ScenarioEvent $event) { $node = $event->getScenario(); $message = " Scenario: " . $node->getTitle() . ' line: ' . $node->getLine(); $this->file = $node->getFile(); $this->line = $node->getLine(); $this->text = $node->getTitle(); $this->node = $node; return $message; }
/** * Listens to "scenario.before" event. * * @param ScenarioEvent $event Event that contains the scenario. */ public function beforeScenario(ScenarioEvent $event) { $this->_client->startScenario($event->getScenario()->getTitle()); }
/** * Keep track of the current scenario and step number for use in the file name * * @param ScenarioEvent $event */ public function resetStepCounter(ScenarioEvent $event) { $this->currentScenario = $event->getScenario(); $this->stepNumber = 0; }
/** * Listens to "scenario.after" event. * * @param ScenarioEvent $event */ public function afterScenario(ScenarioEvent $event) { $scenario = $event->getScenario(); $this->writeln($scenario->getFile() . ':' . $scenario->getLine()); }
/** * @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; }
/** * @param ScenarioEvent|OutlineExampleEvent $event */ public function beforeScenario($event) { if (!$this->enabled) { return; } if ($event instanceof ScenarioEvent) { $this->currentScenarioTitle = $event->getScenario()->getTitle(); $this->currentFeatureTitle = $event->getScenario()->getFeature()->getTitle(); } elseif ($event instanceof OutlineExampleEvent) { $this->currentScenarioTitle = $event->getOutline()->getTitle(); $this->currentFeatureTitle = $event->getOutline()->getFeature()->getTitle(); } else { throw new \InvalidArgumentException(); } $this->currentReport = array('feature' => $this->currentFeatureTitle, 'scenario' => $this->currentScenarioTitle, 'steps' => array()); }