Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scenario_autoretry does not reset runner.hook_failures #1128

Open
rittneje opened this issue Aug 11, 2023 · 3 comments
Open

scenario_autoretry does not reset runner.hook_failures #1128

rittneje opened this issue Aug 11, 2023 · 3 comments

Comments

@rittneje
Copy link

The scenario_autoretry monkey patch does not intervene with or reset the increment of self.hook_failures in the runner. Consequently, if before_scenario/after_scenario fails the first time, and then passes on the retry, behave still exits with failure at the end because hook_failures is non-zero.

self.hook_failures += 1

behave/behave/runner.py

Lines 751 to 755 in 1c6197b

failed = ((failed_count > 0) or self.aborted or (self.hook_failures > 0)
or (len(self.undefined_steps) > undefined_steps_initial_size)
or cleanups_failed)
# XXX-MAYBE: or context.failed)
return failed

@jenisys
Copy link
Member

jenisys commented Aug 11, 2023

Mmh, you seem to have flaky tests.
Therefore, best practice is to fix the flaky tests.

The scenario_autoretry is proof-of-concept code / best-effort code.
Come up with a better solution.

SOLUTION SKETCH:
You probably need to record the test-runner state before the scenario is run to be able to restore this state if you retry a scenario. If the test-runner state currently contains only the hooks_failed count, the solution will become even simpler.

SEE ALSO:

@rittneje
Copy link
Author

rittneje commented Aug 12, 2023

@jenisys Yes obviously we'd prefer the tests not to be flaky. But reality ensues.

I don't know what you mean by the "test-runner state".

@jenisys
Copy link
Member

jenisys commented Aug 12, 2023

Test-runner state (in this case) is any group of variables in the test-runner that you need to restore when you retry a scenario. As already mentioned, this test-runner state contains at least runner.hooks_failed counts (and probably only that variable).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants