Created
September 16, 2016 09:39
-
-
Save mhlavac/a63803fbab314cb8decb449b26ea3663 to your computer and use it in GitHub Desktop.
Codeception retryOnFailure
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
<?php | |
class AcceptanceTester extends \Codeception\Actor | |
{ | |
use _generated\AcceptanceTesterActions; | |
public function retryOnFailure(callable $callback, int $times = 3) | |
{ | |
while ($times > 0) { | |
try { | |
$callback($this); | |
return; | |
} catch (\Exception $exception) { | |
$times--; | |
} | |
} | |
$callback($this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment