Skip to content

Behat Retry

What is the Behat Retry Extension

This extension makes it possible for you tests to re-run on failure while all being done in the background.

The great thing about this is that it does not interrupt your tests by stopping and starting them but instead adds a little bit of time to the total running length of the tests.


All you need to do to install this extension is run the following command:

composer require chekote/behat-retry-extension

What you will need to do next is add the following into your behat.yml file

    # ...
        Chekote\BehatRetryExtension: ~
The above will enable the extension

You are also able to apply some more configuration if you want, examples of which can be seen below

         timeout: 10
         interval: 999999999


PHP Version

What to do if you get the following error:

PHP Parse error: syntax error, unexpected '.', expecting ',' or ';'

This will be cause by the current PHP Version of the container, to solve the problem all you will need to do is upgrade the Version you already have

You can double check you PHP Version with the following command:

php -v

When you have updated your Version be sure to restart PHP to make sure the changes have stuck:

systemctl restart php

You should now be able to run your tests again.

Adding extra configuration

It looks like leaving ~ and the end of the extension name prevents it from working when you add extra configuration.

The error message you will see if you leave it there:

A colon cannot be used in an unquoted mapping value

It is also worth point out that if you do not add any extra configuration it will work fine with ~ at the end.