title: Rerun Failed Behat Tests Only A Set Number of Times
body: <p>I have an Behat testing suite running through Travis CI on Pull Requests. I know that you can add a "--rerun" option to the command line to rerun failed tests, but for me Behat just keeps trying to rerun the failed tests, which eventually times out the test run session.</p>
  
  <p>Is there a way to limit the number of times that failed tests are re-ran? Something like: "behat --rerun=3" for trying to run a failed scenario up to three times?</p>
  
  <p>The only other way I can think to accomplish what I want is to use the database I'm testing Behat against or to write to a file and store test failures and the number of times they have been run. </p>
  
  <p>EDIT:</p>
  
  <p>Locally, running the following command ends up re-running only the one test I purposely made to fail...and it does it in a loop until something happens. Sometimes it was 11 times and sometimes 100+ times.  </p>
  
  <pre><code>behat --tags @some_tag
  behat --rerun 
  </code></pre>
  
  <p>So, that doesn't match what the <a href="http://docs.behat.org/en/v2.5/guides/6.cli.html" rel="nofollow">behat command line guide</a> states. In my terminal, the help option give me "--rerun Re-run scenarios that failed during last execution." without any mention of the failed scenario file. I'm using a 3.0 version of behat though. </p>
  
  <p>Packages used:</p>
  
  <pre><code>    "behat/behat": "~3.0",
      "behat/mink": "~1.5",
      "behat/mink-extension": "~2.0",
      "behat/mink-goutte-driver": "~1.0",
      "behat/mink-selenium2-driver": "~1.1",
      "behat/mink-browserkit-driver": "~1.1",
      "drupal/drupal-extension": "~3.0" 
  </code></pre>
  
  <p>Problem:</p>
  
  <p>Test fail at random due to mainly Guzzle timeout errors going past 30 seconds trying to GET a URL. Sure you could try bumping up the max execution time, but since other tests have no issues and 30 seconds is a long time to wait for a request, I don't think that will fix the issue and it will make my test runs much longer for not a good reason. </p>