Retries
Rerun failing or erroring specs a few times before reporting them, per spec, per bundle or for the whole run.
Browser tests talk to a real browser, a real server and sometimes real third-party services, so a spec can fail once for reasons that have nothing to do with your code. Retries run a failing or erroring spec again, up to a number of extra times, and report the final attempt. They work for every spec, browser or not, BDD or xUnit, on every engine.

How a Retry Runs
When an attempt fails or errors and attempts remain, TestBox runs the whole spec life-cycle again:
BDD: every
beforeEach(), thearoundEach()closures, the spec body and everyafterEach().xUnit:
setup(), the test method (with its expected exception checks) andteardown().
The spec passes as soon as one attempt passes. When every attempt fails, the spec reports the failure or error of the last attempt. Skipped specs (skip(), xit(), a skip constraint) are never retried. Files attached during earlier attempts stay on the spec, so you keep the screenshots of every failed attempt.
Declaring Retries
On a spec: the retries argument
it(), fit() and xit() take a retries argument: how many extra times to run the spec. retries = 2 means up to three attempts.
On a bundle: the retries annotation
A retries annotation on the bundle class applies to every spec of the bundle that does not declare its own.
On an xUnit test: the retries method annotation
xUnit test methods take a retries annotation, which wins over the bundle annotation.
For the whole run: the retries option
Give every spec that declares nothing a default with the retries runner option. On the BoxLang CLI runner:
Or through the options of TestBox when you run tests from code:
Precedence
TestBox resolves the retries of a spec in this order, and the first match wins:
1
The spec: it( ..., retries = N ) or the xUnit retries method annotation
Only when greater than 0. 0, the default, means "inherit".
2
The bundle retries annotation
Any number, so @retries( 0 ) (or retries="0" on a CFML component) turns retries off for the bundle, even when the run sets a global value.
3
The global retries runner option (--retries=N)
Applies to specs and bundles that declare nothing.
4
None
0: every spec runs once.
Attempts in the Results
Every spec records how many times it ran in the attempts key of its stats: 1 for a spec that ran once, more for a retried spec. Reporters call out specs that needed more than one attempt, for example in the text reporter:
The text, console and Simple reporters and the BoxLang runner --stream output show the note. The JSON and Raw reports carry attempts for every spec, so your CI can flag flaky specs:
Retries and --failed
Retries handle a hiccup inside one run. To rerun only what failed after the run is over, use the BoxLang runner --failed option. The two combine well: ./testbox/run --failed --retries=1.
Last updated
Was this helpful?