Skip to content

Instantly share code, notes, and snippets.

@mhlavac
Created September 16, 2016 09:39
Show Gist options
  • Save mhlavac/a63803fbab314cb8decb449b26ea3663 to your computer and use it in GitHub Desktop.
Save mhlavac/a63803fbab314cb8decb449b26ea3663 to your computer and use it in GitHub Desktop.
Codeception retryOnFailure
<?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