You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem:
Tests have no way to retry without manually managing `before_each` and
`after_each` setup/teardown. This is painful. And busted does a good job
of guarding its internals and makes it impossible to extend it: AFAICT,
consumers have no way to access the current "test context", or the
current list of `before_each`/`after_each` hooks.
Solution:
Introduce `env.set_retries()`. On failure the test is retried up to `n`
more times, rerunning `after_each`/`before_each` around each attempt.
`busted.safe()` gains an optional `deferred` collector so only the final
attempt's failure/error/pending events are published: output handlers
and the exit code never see non-final attempts.
```lua
it('...', function()
set_retries(2) -- If the test fails, it will be retried up to 2 times.
end)
```
Testing:
luarocks --local remove busted --force && luarocks --local make && ~/.luarocks/bin/busted --pattern=core
Note: Deferral shifts event timing slightly: a failing test's
failure/error event is now published after its `finally` runs, not
before. Relative event order is unchanged; in-tree handlers can't
observe the difference.
0 commit comments