Exemplo n.º 1
0
 /**
  * Listens to "scenario.before" event.
  *
  * @param BeforeScenarioTested $event
  */
 public function beforeScenario(BeforeScenarioTested $event)
 {
     if ('scenario' !== $this->lifetime) {
         return;
     }
     list($adapter, $fixtureClass) = $this->extractAdapterConfig($event->getFeature()->getTags());
     $this->executor->changeAdapter($adapter, $fixtureClass);
     $this->executor->purge();
 }
 /**
  * beforeExample
  * @param  BeforeScenarioTested $event object
  * @return null
  */
 public function beforeExample(BeforeScenarioTested $event)
 {
     $this->currentScenario = $event->getScenario();
     $this->testResults->addScenario($this->currentFeature, $this->currentScenario);
 }
 /**
  * @param BeforeScenarioTested $event
  */
 public function onBeforeScenarioTested(BeforeScenarioTested $event)
 {
     $scenario = new Scenario();
     $scenario->setName($event->getScenario()->getTitle());
     $scenario->setTags($event->getScenario()->getTags());
     $scenario->setLine($event->getScenario()->getLine());
     $this->currentScenario = $scenario;
     $print = $this->renderer->renderBeforeScenario($this);
     $this->printer->writeln($print);
 }
 /**
  * @param BehatEvent\BeforeScenarioTested $event
  */
 public function onBeforeScenarioTested(BehatEvent\BeforeScenarioTested $event)
 {
     $scenario = new Node\Scenario();
     $scenario->setName($event->getScenario()->getTitle());
     $scenario->setTags($event->getScenario()->getTags());
     $scenario->setLine($event->getScenario()->getLine());
     $scenario->setType($event->getScenario()->getNodeType());
     $scenario->setKeyword($event->getScenario()->getKeyword());
     $scenario->setFeature($this->currentFeature);
     $this->currentScenario = $scenario;
 }
 /**
  * @param BeforeScenarioTested $event
  */
 public function onBeforeScenarioTested(BeforeScenarioTested $event)
 {
     $scenario = new Scenario();
     $scenario->setName($event->getScenario()->getTitle());
     $scenario->setTags($event->getScenario()->getTags());
     $scenario->setLine($event->getScenario()->getLine());
     $scenarioName = $event->getScenario()->getTitle();
     $scenarioName = preg_replace('/[^A-Za-z0-9]/', ' ', $scenarioName);
     $scenarioName = trim(preg_replace('/\\s+/', ' ', $scenarioName));
     $scenarioName = str_replace(' ', '_', $scenarioName);
     $scenarioNameMD5 = md5($scenarioName);
     $scenarioOutlineName = $this->currentScenarioOutline;
     $scenarioOutlineName = str_replace(' ', '_', $scenarioOutlineName);
     $scenarioOutlineName = substr($scenarioOutlineName, 0, 25);
     $scenarionType = $this->currentScenarioType;
     $breakPointArrayValue = "";
     if ($scenarionType === "Scenario Outline") {
         $breakPointArrayKey = array_key_exists("screen resolution", $event->getScenario()->getTokens()) ? "screen resolution" : "breakpoint";
         $breakPointArrayValue = $event->getScenario()->getTokens()[$breakPointArrayKey];
     } else {
         $scenarioOutlineName = $event->getScenario()->getTitle();
         $scenarioOutlineName = str_replace(' ', '_', $scenarioOutlineName);
         $scenarioOutlineName = substr($scenarioOutlineName, 0, 25);
     }
     $scenarioFolder = $scenarioOutlineName . "__" . $breakPointArrayValue . "__" . $scenarioNameMD5;
     $scenario->setScreenshotName($scenarioFolder);
     $this->currentScenario = $scenario;
     $this->getCurrentFeature();
     $print = $this->renderer->renderBeforeScenario($this);
     /*Old logic*/
     /*$this->printer->writeln($print);*/
     /*New logic*/
     //$featureName = $this->getCurrentFeature()->getName();
     $featureName = $this->getCurrentFeature()->getFileName();
     $this->printer->featureWriteln($print, $featureName);
 }
 /**
  * @param BeforeScenarioTested $event
  */
 public function onBeforeScenarioTested(BeforeScenarioTested $event)
 {
     $this->printEvent("testStarted", array('name' => $event->getScenario()->getTitle()));
 }