forked from michalochman/SilverStripeExtension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bd1452
commit 404195b
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace SilverStripe\BehatExtension\Utility; | ||
|
||
use Behat\Behat\Tester\ScenarioTester; | ||
use Behat\Gherkin\Node\FeatureNode; | ||
use Behat\Gherkin\Node\ScenarioInterface; | ||
use Behat\Testwork\Environment\Environment; | ||
use Behat\Testwork\Tester\Result\TestResult; | ||
|
||
/** | ||
* This tester will retry a scenario if it fails | ||
*/ | ||
class RetryScenarioTester implements ScenarioTester | ||
{ | ||
private ScenarioTester $decoratedTester; | ||
|
||
public function __construct(ScenarioTester $decoratedTester) | ||
{ | ||
$this->decoratedTester = $decoratedTester; | ||
} | ||
|
||
public function setUp(Environment $env, FeatureNode $feature, ScenarioInterface $scenario, $skip) | ||
{ | ||
return $this->decoratedTester->setUp($env, $feature, $scenario, $skip); | ||
} | ||
|
||
public function test(Environment $env, FeatureNode $feature, ScenarioInterface $scenario, $skip) | ||
{ | ||
$result = $this->decoratedTester->test($env, $feature, $scenario, $skip); | ||
if (!$skip && !$result->isPassed()) { | ||
// Run the scenario again | ||
$result = $this->decoratedTester->test($env, $feature, $scenario, $skip); | ||
} | ||
return $result; | ||
} | ||
|
||
public function tearDown(Environment $env, FeatureNode $feature, ScenarioInterface $scenario, $skip, TestResult $result) | ||
{ | ||
return $this->decoratedTester->tearDown($env, $feature, $scenario, $skip, $result); | ||
} | ||
} |