-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Fix: retried scenarios which are run after another scenario with a passed result are still counted as failed #250
Conversation
The original post sounds like quite a big bug, which has not been encountered by myself in years of running this. Can you maybe share a reproducible script that generates the failures you mention. The specs/tests are a little hard to follow, but I think I need a better understanding of where this error comes from first. |
Hi @luke-hill ,
Most of the time, if we use the built-in However, sometimes, we might want to have a custom way to retry those failed scenarios, for example: retry the failed scenarios after all the scenarios have been run. With this case, the condition This PR improves the cucumber retry so that it works for both cases: retry immediately right after 1 failed scenario, or retry later after other scenarios too.
Sure, I have created this Github repo to test - just need to run I also attached the screenshots below for the differences when running the cucumber tests before and after this PR: Before (with cucumber-core v11.1.0) After (with this PR) Let me know if you have any other questions! |
I'll need a good few weeks owing to other responsibilities to check on this. So apologies in advance. Everything you've given looks enough for me for now to repro |
Hi @thukim As/when I get around to releasing a v12 version of this gem (Nothing huge changing don't worry). This PR will need a rebase and slight fix / re-gen of the rubocop TODO file. I'll then plan during the v12 phase to start clicking off some of the offenses (Which number 2k+) |
Hi @luke-hill , Sorry for the late reply! I have been able to switch back to this PR and resolved the conflicts. Please let me know if there is any thing else I need to update/add in the PR. Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there. I've not forgot about this, just I've got 7 or 8 other things I'm trying to fix up atm. I will get to reviewing this in the next week or so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few language tweaks and a request to re-structure the tests to help the next person coming to read them
@@ -17,6 +17,7 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo | |||
See upgrading notes for [13.0.0.md](upgrading_notes/13.0.0.md#upgrading-to-1300) | |||
([#261](https://github.com/cucumber/cucumber-ruby-core/pull/261)) | |||
- Permit usage of gherkin v27 | |||
- Fixed retried scenarios which are run after another scenario with a passed result are still counted as failed ([#250](https://github.com/cucumber/cucumber-ruby-core/pull/250) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you place this under a ### Fixed heading
event_bus.send(:test_case_finished, test_case, passed_result) | ||
end | ||
|
||
it 'reports 0 passed test' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests
when using 0
as an input number or 2+
test
when using 1
as an input number
allow(test_case).to receive(:==).and_return(false, true) | ||
event_bus.send(:test_case_finished, test_case, failed_result) | ||
event_bus.send(:test_case_finished, test_case, passed_result) | ||
context 'handles flaky test cases' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible it would be better to write each of these as just 1 level of nesting under context with a better description. It's a bit hard for me to work out what's different here. Admittedly I don't know the code that well.
Description
Issue: Retried scenarios which are run after another scenario with a passed result are still counted as failed
Tests written to ensure the fix works: https://github.com/cucumber/cucumber-ruby-core/pull/250/files#diff-9bded15ebb1a2a9b74f58b63b24f0ff35f75c5cc44037e14b976ef1f3fde87d5R85-R112
Proposed changes:
@previous_test_case
to@previous_test_cases
which is a Ruby Set object, so that it holds a collection of all the unique test scenarios which have been run, regardless whether they pass or fail.@previous_test_case
value, the current event.test_case will be checked if it's included in the set@previous_test_cases
. This ensures regardless whether the retried test case is run immediately after that test case or after another test case, it is still counted as retried one instead of a new test case as with the current logic.These changes are backward compatible and don't impact future contributions, so I only bump the patch version, from 11.1.0 to 11.1.1
Please let me know if there is anything else I need to add or fix in this PR.
Thanks!
Type of change
Please delete options that are not relevant.
Checklist:
Your PR is ready for review once the following checklist is
complete. You can also add some checks if you want to.
bundle exec rubocop
reports no offenses