4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Behat\Tester\Runtime;
13 use Behat\Behat\Tester\OutlineTester;
14 use Behat\Behat\Tester\ScenarioTester;
15 use Behat\Gherkin\Node\FeatureNode;
16 use Behat\Gherkin\Node\OutlineNode;
17 use Behat\Testwork\Environment\Environment;
18 use Behat\Testwork\Tester\Result\IntegerTestResult;
19 use Behat\Testwork\Tester\Result\TestResult;
20 use Behat\Testwork\Tester\Result\TestResults;
21 use Behat\Testwork\Tester\Result\TestWithSetupResult;
22 use Behat\Testwork\Tester\Setup\SuccessfulSetup;
23 use Behat\Testwork\Tester\Setup\SuccessfulTeardown;
26 * Tester executing outline tests in the runtime.
28 * @author Konstantin Kudryashov <ever.zet@gmail.com>
30 final class RuntimeOutlineTester implements OutlineTester
35 private $scenarioTester;
40 * @param ScenarioTester $scenarioTester
42 public function __construct(ScenarioTester $scenarioTester)
44 $this->scenarioTester = $scenarioTester;
50 public function setUp(Environment $env, FeatureNode $feature, OutlineNode $outline, $skip)
52 return new SuccessfulSetup();
58 public function test(Environment $env, FeatureNode $feature, OutlineNode $outline, $skip = false)
61 foreach ($outline->getExamples() as $example) {
62 $setup = $this->scenarioTester->setUp($env, $feature, $example, $skip);
63 $localSkip = !$setup->isSuccessful() || $skip;
64 $testResult = $this->scenarioTester->test($env, $feature, $example, $localSkip);
65 $teardown = $this->scenarioTester->tearDown($env, $feature, $example, $localSkip, $testResult);
67 $integerResult = new IntegerTestResult($testResult->getResultCode());
68 $results[] = new TestWithSetupResult($setup, $integerResult, $teardown);
71 return new TestResults($results);
77 public function tearDown(Environment $env, FeatureNode $feature, OutlineNode $outline, $skip, TestResult $result)
79 return new SuccessfulTeardown();