/**
  * {@inheritdoc}
  */
 public function test(Environment $env, FeatureNode $feature, Scenario $scenario, $skip)
 {
     $isolatedEnvironment = $this->envManager->isolateEnvironment($env, $scenario);
     $setup = $this->decoratedTester->setUp($isolatedEnvironment, $feature, $scenario, $skip);
     $localSkip = !$setup->isSuccessful() || $skip;
     $testResult = $this->decoratedTester->test($isolatedEnvironment, $feature, $scenario, $localSkip);
     $teardown = $this->decoratedTester->tearDown($isolatedEnvironment, $feature, $scenario, $localSkip, $testResult);
     $integerResult = new IntegerTestResult($testResult->getResultCode());
     return new TestWithSetupResult($setup, $integerResult, $teardown);
 }
Example #2
0
 /**
  * @param array $steps
  * @param Suite $suite
  * @return \Behat\Behat\Tester\Result\StepResult
  */
 public function run($steps, Suite $suite)
 {
     $env = $this->environmentManager->buildEnvironment($suite);
     $env = $this->environmentManager->isolateEnvironment($env);
     $dummyFeatureNode = $this->generator->generate($steps);
     $featureNode = $dummyFeatureNode->getFeatureNode();
     foreach ($dummyFeatureNode->getStepNodes() as $stepNode) {
         $this->stepTester->setUp($env, $featureNode, $stepNode, false);
         $result = $this->stepTester->test($env, $featureNode, $stepNode, false);
         $this->stepTester->tearDown($env, $featureNode, $stepNode, false, $result);
     }
     return $result;
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function test(array $iterators, $skip = false)
 {
     $results = array();
     foreach (GroupedSpecificationIterator::group($iterators) as $iterator) {
         $environment = $this->envManager->buildEnvironment($iterator->getSuite());
         $setup = $this->suiteTester->setUp($environment, $iterator, $skip);
         $localSkip = !$setup->isSuccessful() || $skip;
         $testResult = $this->suiteTester->test($environment, $iterator, $localSkip);
         $teardown = $this->suiteTester->tearDown($environment, $iterator, $localSkip, $testResult);
         $integerResult = new IntegerTestResult($testResult->getResultCode());
         $results[] = new TestWithSetupResult($setup, $integerResult, $teardown);
     }
     return new TestResults($results);
 }
 /**
  * {@inheritdoc}
  */
 public function test(Environment $env, $feature, $skip = false)
 {
     $results = array();
     foreach ($feature->getScenarios() as $scenario) {
         $isolatedEnvironment = $this->envManager->isolateEnvironment($env, $scenario);
         $tester = $scenario instanceof OutlineNode ? $this->outlineTester : $this->scenarioTester;
         $setup = $tester->setUp($isolatedEnvironment, $feature, $scenario, $skip);
         $localSkip = !$setup->isSuccessful() || $skip;
         $testResult = $tester->test($isolatedEnvironment, $feature, $scenario, $localSkip);
         $teardown = $tester->tearDown($isolatedEnvironment, $feature, $scenario, $localSkip, $testResult);
         $integerResult = new IntegerTestResult($testResult->getResultCode());
         $results[] = new TestWithSetupResult($setup, $integerResult, $teardown);
     }
     return new TestResults($results);
 }
 /**
  * Returns all available definitions for a specific environment.
  *
  * @param Environment $environment
  *
  * @return Definition[]
  *
  * @throws RedundantStepException
  */
 public function getEnvironmentDefinitions(Environment $environment)
 {
     $patterns = array();
     $definitions = array();
     foreach ($this->environmentManager->readEnvironmentCallees($environment) as $callee) {
         if (!$callee instanceof Definition) {
             continue;
         }
         $pattern = $callee->getPattern();
         if (isset($patterns[$pattern])) {
             throw new RedundantStepException($callee, $patterns[$pattern]);
         }
         $patterns[$pattern] = $callee;
         $definitions[] = $callee;
     }
     return $definitions;
 }
 public function test(Environment $env, $feature, $skip)
 {
     $results = array();
     foreach ($feature->getScenarios() as $scenario) {
         $isolatedEnvironment = $this->envManager->isolateEnvironment($env, $scenario);
         $block = new AroundHookScenarioBlock($scenario, $isolatedEnvironment, $feature, $skip, $this->scenarioTester, $this->outlineTester, $this->envManager);
         $scope = new AroundScenarioScope($isolatedEnvironment, $feature, $scenario, $block);
         $hookCallResults = $this->hookDispatcher->dispatchScopeHooks($scope);
         foreach ($hookCallResults as $callResult) {
             echo $callResult->getStdOut();
             if ($callResult->hasException()) {
                 throw $callResult->getException();
             }
         }
         if (count($hookCallResults) == 0) {
             $block->call();
         }
         $results = array_merge($results, $block->getResults());
     }
     return new TestResults($results);
 }
Example #7
0
 /**
  * Prints definitions for provided suite using printer.
  *
  * @param DefinitionPrinter $printer
  * @param Suite             $suite
  */
 public function printSuiteDefinitions(DefinitionPrinter $printer, $suite)
 {
     $environment = $this->environmentManager->buildEnvironment($suite);
     $definitions = $this->repository->getEnvironmentDefinitions($environment);
     $printer->printDefinitions($suite, $definitions);
 }
Example #8
0
 /**
  * Returns all available hooks for a specific environment.
  *
  * @param Environment $environment
  *
  * @return Hook[]
  */
 public function getEnvironmentHooks(Environment $environment)
 {
     return array_filter($this->environmentManager->readEnvironmentCallees($environment), function (Callee $callee) {
         return $callee instanceof Hook;
     });
 }