Repository navigation
Let a retry policy decide will_be_retried in the runner #345
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
66f3a62
Specify the TestCaseFinished envelope of a retried test case
Enceradeira 52656e0
Let a retry policy decide will_be_retried in the runner
Enceradeira 9ab0226
Make the optional runner constructor arguments keyword arguments
Enceradeira f398b79
Default the runner to a retry policy that never retries
Enceradeira 6944446
Namespace the retry policy example in the upgrading notes
Enceradeira ecd3dd9
Specify the runner asks NoRetries by default and honours a given retr…
Enceradeira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Cucumber | ||
| module Core | ||
| module Test | ||
| class NoRetries | ||
| def will_be_retried?(_test_case, _result) = false | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Upgrading to cucumber-core 20.0.0 | ||
|
|
||
| ## Retry policy for the Test Runner | ||
|
|
||
| In cucumber-core 19.0.0 the `Cucumber::Core::Test::Runner` started to emit the `TestCaseFinished` envelope itself, and | ||
| decided the value of its `will_be_retried` field from a maximum number of attempts passed to its constructor. The | ||
| runner cannot know that on its own: whether a test case is retried is decided by whoever runs it again (in | ||
| cucumber-ruby, the retry filter, which also honours `--retry-total`), so the two got out of sync. | ||
|
|
||
| The runner now takes a retry policy instead, and its optional constructor arguments (`id_generator`, `backtrace_filter` | ||
| and `retry_policy`) became keyword arguments. The policy is asked, every time a test case finishes, whether that test | ||
| case will be run again. It has to answer without side effects, as it is asked before the | ||
| `test_case_finished` event is broadcast. | ||
|
|
||
| ### Before cucumber-core 20.0.0 | ||
|
|
||
| ```ruby | ||
| runner = Cucumber::Core::Test::Runner.new(event_bus, id_generator, backtrace_filter, max_attempts) | ||
| ``` | ||
|
|
||
| ### With cucumber-core 20.0.0 | ||
|
|
||
| ```ruby | ||
| module MyProject | ||
| # For the policy cucumber-ruby uses, see lib/cucumber/retry_policy.rb in cucumber-ruby | ||
| class RetryPolicy | ||
| def will_be_retried?(test_case, result) | ||
| result.failed? && attempts_so_far(test_case) < max_attempts | ||
| end | ||
| end | ||
| end | ||
|
|
||
| runner = Cucumber::Core::Test::Runner.new( | ||
| event_bus, | ||
| id_generator: id_generator, | ||
| backtrace_filter: backtrace_filter, | ||
| retry_policy: MyProject::RetryPolicy.new | ||
| ) | ||
| ``` | ||
|
|
||
| When no retry policy is given, the runner uses `Cucumber::Core::Test::NoRetries`, which never reports a test case as | ||
| retried. `Cucumber::Core::Test::Runner.new(event_bus)` keeps working as before. | ||
|
|
||
| ## Envelope ordering | ||
|
|
||
| The runner now emits the `TestCaseFinished` envelope before it broadcasts the `test_case_finished` event. Handlers of | ||
| that event that run the test case again therefore see the envelope of the previous attempt already emitted. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.