Even though I am aware of the fact that tests should run reliably, my experience tells me: that cannot always be accomplished with reasonable effort (and need not be accomplished; see my calculation below).
Particularly, if tests are introduced for a pre-existing Web application that needs to be persistently improved, it can be difficult to build reliable E2E tests. But, in contrast, it is pretty easy and besides sufficient to build tests which crash occasionally (as long as they fail reliably when it comes to expects/asserts).
If you are using Protractor for E2E testing, you may have experienced that as well.
Statistics tell me that a test that is known to have a 25% chance to crash, will have a 6.25% chance to crash twice when run twice, a 1.56% chance to crash three times when run three times, a 0.39% chance to crash four times when run four times and a 0.10% chance to crash five times when run five times (and so on).
Hence, running a set of such tests until each of them manages to terminate without error is no big deal.
My demand is to run a Cucumber.js scenario again and again until it succeeds for the first time during a single feature run, and then take the test pass/fail result of the succeeding run.
I tried to build an After
hook that re-runs the scenario but I did not find a way of invoking a scenario from within the hook. Apart from that, I did not find a way of discarding a crashing scenario run.
Please tell me which options I have. I am using Grunt, Protractor and Cucumber.
Since our test suite is huge, still growing rapidly and run by an automated build process, I need a way of running unreliable tests as reliably as possibly.