Closed iftheshoefritz closed 2 years ago
There's no obvious workaround for this that comes to mind. Unless re-running the whole suite without flaky ones is an option.
Your use case resonates with my experience, I'd much rather prefer marking specs as flaky and fix them in a bulk rather than in scope of an unrelated PR with red CI due to flakiness.
@JonRowe Would it make sense to introduce a :flaky
metadata handler/example alias, similar to pending
/skip
?
Example result | pending |
skip |
flaky |
---|---|---|---|
pass | failure | - | pass |
fail | pass | - | pass |
Have you checked you've setup the hook properly? i.e. that its actually running at all?
The hook runs, but the test fails without reaching the rescue block.
This is as expected, we catch those exceptions deeper and only re-raise them in matchers that include expectations (see https://github.com/rspec/rspec-expectations/pull/892).
You should be able to check the examples run status to see if it has failed.
Subject of the issue
I've got a rescue block around
example.run
in anaround
hook. The test fails and exits without running the code in the rescue block.Context: I'm trying to create a label that when applied will mark an example pending only if it fails; i.e. if it passes I do not want it to make the entire suite fail the way
pending
does.Your environment
Ruby version:
rspec-core version:
Steps to reproduce
I based this around hook on an old stack overflow post
Expected behaviour
I expect the failed expect call to be caught, the test to be marked pending, and then the failure to be raised again.
Actual behavior
The rescue block never executes and I get the standard failure:
Happy to hear other approaches for achieving this goal if hooks just don't work this way.