4 * This file is part of the Behat Testwork.
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\Testwork\Tester\Runtime;
13 use Behat\Testwork\Environment\Environment;
14 use Behat\Testwork\Specification\SpecificationIterator;
15 use Behat\Testwork\Tester\Result\IntegerTestResult;
16 use Behat\Testwork\Tester\Result\TestResult;
17 use Behat\Testwork\Tester\Result\TestResults;
18 use Behat\Testwork\Tester\Result\TestWithSetupResult;
19 use Behat\Testwork\Tester\Setup\SuccessfulSetup;
20 use Behat\Testwork\Tester\Setup\SuccessfulTeardown;
21 use Behat\Testwork\Tester\SpecificationTester;
22 use Behat\Testwork\Tester\SuiteTester;
25 * Tester executing suite tests in the runtime.
27 * @author Konstantin Kudryashov <ever.zet@gmail.com>
29 final class RuntimeSuiteTester implements SuiteTester
32 * @var SpecificationTester
39 * @param SpecificationTester $specTester
41 public function __construct(SpecificationTester $specTester)
43 $this->specTester = $specTester;
49 public function setUp(Environment $env, SpecificationIterator $iterator, $skip)
51 return new SuccessfulSetup();
57 public function test(Environment $env, SpecificationIterator $iterator, $skip = false)
60 foreach ($iterator as $specification) {
61 $setup = $this->specTester->setUp($env, $specification, $skip);
62 $localSkip = !$setup->isSuccessful() || $skip;
63 $testResult = $this->specTester->test($env, $specification, $localSkip);
64 $teardown = $this->specTester->tearDown($env, $specification, $localSkip, $testResult);
66 $integerResult = new IntegerTestResult($testResult->getResultCode());
67 $results[] = new TestWithSetupResult($setup, $integerResult, $teardown);
70 return new TestResults($results);
76 public function tearDown(Environment $env, SpecificationIterator $iterator, $skip, TestResult $result)
78 return new SuccessfulTeardown();