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\BackgroundTester;
14 use Behat\Behat\Tester\Exception\FeatureHasNoBackgroundException;
15 use Behat\Behat\Tester\StepContainerTester;
16 use Behat\Gherkin\Node\FeatureNode;
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\Setup\SuccessfulSetup;
22 use Behat\Testwork\Tester\Setup\SuccessfulTeardown;
25 * Tester executing background tests in the runtime.
27 * @author Konstantin Kudryashov <ever.zet@gmail.com>
29 final class RuntimeBackgroundTester implements BackgroundTester
32 * @var StepContainerTester
34 private $containerTester;
39 * @param StepContainerTester $containerTester
41 public function __construct(StepContainerTester $containerTester)
43 $this->containerTester = $containerTester;
49 public function setUp(Environment $env, FeatureNode $feature, $skip)
51 return new SuccessfulSetup();
57 public function test(Environment $env, FeatureNode $feature, $skip)
59 $background = $feature->getBackground();
61 if (null === $background) {
62 throw new FeatureHasNoBackgroundException(sprintf(
63 'Feature `%s` has no background that could be tested.',
68 if (!$background->hasSteps()) {
69 return new IntegerTestResult(TestResult::PASSED);
72 $results = $this->containerTester->test($env, $feature, $background, $skip);
74 return new TestResults($results);
80 public function tearDown(Environment $env, FeatureNode $feature, $skip, TestResult $result)
82 return new SuccessfulTeardown();