-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add --retry option to retry failed tests as part of the same run #920
Conversation
Looks like a good start but there's no implementation right? So the tests should not be passing... or did I misunderstand something? |
You could usefully rebase your branch (you can use |
I think I was the one who misunderstood something. A while ago you said something about failing features being the first step, and I assumed that meant you wanted a PR with the tests. I’m giving a 45-minute talk tonight so things have been kind of crazy, but I’ll have a chance to work on this more later this week. And re:
|
Comprende! I was confused because the branch was green, but that's because you've changed the travis config is it? So yeah I think those scenarios are a good place to start. We need to update the description a bit to align with what we've decided (i.e. deferring things like using tags). |
You happy to have a crack at an implementation Dana? Give me a shout if you need some support. Thanks for taking interest in this! |
@mattwynne |
I'm totally working on it already, just didn't want to pollute the existing PR with all the new commits so I switched to a different branch & will merge later. |
Happy to help! |
OK. I've put the WIP tag on this PR, so it would work well for me if you just use this branch as you work on the solution, |
That works for me. I should have some time to work on this tomorrow as I just finished a couple other projects that were taking up my time.
|
OK, I didn't end up getting to this today because my server got rooted and I had to fix everything. Keeping my fingers crossed for tomorrow! |
Friday is OSS day so that's good. Grab me in https://gitter.im/cucumber/cucumber-ruby if you want to chat. |
43dac6a
to
7a25d81
Compare
def test_case(test_case) | ||
super | ||
|
||
configuration.on_event(:after_test_case) do |event| |
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.
I'd have thought you'd need to register the event listener earlier than this, like maybe in the filter's constructor. Does it work?
@mattwynne I got a little stuck trying to figure out why the one spec on this still fails. It seems to be saying that when there's a failing test (not a flaky one), it's only retrying once, even though the configuration options say it should be retried twice. Am I missing something obvious? |
I have a flight on Monday when I should be able to give this some focus. Can you push up whatever you have (use another branch if you want) and I'll get my head around it then? Thanks for your patience @danascheider. |
@mattwynne No problem, I'm pretty sure what's on this branch is all I have at this point, but I'll check my home laptop for more and push anything I find. I've been really busy too, so no worries. |
@danascheider FINALLY I got a chance to look at this 😀. I'm lucky enough to have @brasmusson in the same room as me today, and we figured out some subtle problems that were preventing the retry filter from working quite right. We pushed them here: 8f9445f for you to take a look at. I wouldn't copy the changes line-for-line as we were messing around quite a bit and probably changed more than is necessary. I'll put some comments on that diff to show you the interesting bits. FYI, the acceptance test now seems to be failing for another reason - even when a test has been retried, the summary still shows |
@mattwynne Thank you! I'll take a look at it too. |
Hi @danascheider, just checking in to see how you're feeling about this one. I'm deliberately leaving it so you can get the sense of satisfaction from finishing it. Is there anything blocking you right now that I can help with? |
Oh, thanks, @mattwynne. It's on my list, I'm just working a lot and in the middle of moving so I had it on the back burner. |
👍🚚💼 Take your time @danascheider, I think you have most of the puzzle pieces now. The existing code for the summary numbers in the formatters is a bit of a muddle but that's a problem we can deal with when you've got the main behaviour working. |
Redo the commit I just reverted but with the file I intended to include the first time
Change Retry filter to have attribute :configuration and first pass at setting up a listener Reorganize spec file Finish adding tests for re-running flaky test cases - all but one pass Fix spec that said to test what happens when a test case passes but actually didn't make sure it did pass
Define steps for the retry feature
7a25d81
to
d5979ad
Compare
Got all the tests passing - any other thoughts, @mattwynne or @brasmusson? What was the problem with the formatter for the summary numbers? |
An reasonable output from the progress formatter in case of one scenario that passed, one scenario that passed after one retry, one scenario that passed after two retries, and one scenario that still failed after two retries could be:
A problem with the implementation is that the summary is provided by the Console module, it is used both by the pretty formatter and the progress formatter (and peoples custom formatter), and the progress formatter is on the way to be fully based on events (#977) using the Summary class from the Core , whereas the pretty formatter is still using the legacy formatter API. To implement what is needed to produce a summary as the one above which works for all the APIs that formatters uses seems to be - how should I put it - not trivial. |
Classic Swedish understatement @brasmusson! Actually I don't think it will be that hard, but equally I think it's an enhancement. With what @danascheider's already done, the thing is usable and useful. We can improve on the reporting in another iteration IMO. Thoughts? |
@@ -32,6 +32,70 @@ | |||
create_step_definition { string } | |||
end | |||
|
|||
Given /^a scenario "([^\"]*)" that fails once, then passes$/ do |name| |
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.
Do you think maybe these should go into a retry_steps.rb
? They're quite specific...
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.
Done.
There's lot of commits here. Probably best to squash when this gets merged? Unless you want to rebase @danascheider? |
Sure, they can be squashed. |
private | ||
|
||
def retry_required?(test_case, event) | ||
event.test_case == test_case && event.result.failed? && test_case_counts[test_case] < configuration.retry_attempts |
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.
This does not work, since the test_case you pass on is never the same that are in the after_test_case
event. Filters like activate_steps call Case#with_steps which creates a new test case object.
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.
I've resolved this with cucumber/cucumber-ruby-core#111 which makes equality for Test::Case
objects work as you would expect it to.
…umber#920) * Add feature file from PR 895 to start work on retry functionality * Initial spec for --retry option * Add another test for --retry flag, make new tests pass * Squash some commits Redo the commit I just reverted but with the file I intended to include the first time * Rebase onto master * Allow for --retry option in configuration Add retry_attempts method to configuration base class Add Retry formatter and specs for same Remove files attempting to implement --retry with a formatter - bad idea Add wip tag to prevent --retry features from killing the build Actually run Travis build against active branch Fix tiny grammatical error. Closes cucumber#914. * Update scenarios to look like @mattwynne's suggestion * Initial specs for retry filter - they test if it works at all, basically Change Retry filter to have attribute :configuration and first pass at setting up a listener Reorganize spec file Finish adding tests for re-running flaky test cases - all but one pass Fix spec that said to test what happens when a test case passes but actually didn't make sure it did pass * Add consistently failing scenario to test cases Define steps for the retry feature * Correct # of retries * Refactor test case * Make method private * Extract retry_required? method * Move steps for retry filter into other file * Correct block style
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Here are the features I wrote up for #882. Let me know what you think, @mattwynne and @brasmusson. Travis isn't passing but it's those wire protocol features again - shouldn't have been affected by what I wrote.