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

Retry failed Scenarios (#212) #223

Merged
merged 71 commits into from
Sep 8, 2022
Merged

Retry failed Scenarios (#212) #223

merged 71 commits into from
Sep 8, 2022

Conversation

ilslv
Copy link
Member

@ilslv ilslv commented Jul 22, 2022

Resolves #212
Superseeds #214

Synopsis

For now there is no way to retry failed Scenarios.

Solution

Implement ability to implement retries of failed Scenarios with:

  1. Tags @retry/@retry(3)/@retry.after(3s)/@retry(5).after(all)
  2. CLI options --retry=3/--retry-after=30ms/--retry-after=all

Checklist

  • Created PR:
    • In draft mode
    • Name contains Draft: prefix
    • Name contains issue reference
    • Has assignee
  • Documentation is updated (if required)
  • Tests are updated (if required)
  • Changes conform code style
  • CHANGELOG entry is added (if required)
  • FCM (final commit message) is posted
    • and approved
  • Review is completed and changes are approved
  • Before merge:
    • Milestone is set
    • PR's name and description are correct and up-to-date
    • Draft: prefix is removed
    • All temporary labels are removed

@ilslv ilslv marked this pull request as ready for review August 11, 2022 13:46
@ilslv ilslv changed the title Draft: Retry failed Scenarios (#212) Retry failed Scenarios (#212) Aug 11, 2022
@ilslv
Copy link
Member Author

ilslv commented Aug 11, 2022

FCM

Add ability to retry failed `Scenario`s (#223, #212)

- add `--retry`, `--retry-after` and `--retry-tag-filter` CLI options
- describe retrying in a separate Book chapter
- add `writer::Stats::retried_steps()` method
- wrap `event::Scenario` into `event::RetryableScenario` for storing in other `event`s

src/event.rs Outdated

/// [`Scenario`] execution being finished.
///
/// [`Scenario`]: gherkin::Scenario
Finished,
Finished(Option<Retries>),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilslv maybe decomposition would be better here?

pub struct RetryableScenario<World> {
    pub event: Scenation<World>,
    pub retries: Option<Retries>,
}

So we don't pollute the Scenario enum variants with Option.

src/cli.rs Show resolved Hide resolved
@@ -121,6 +272,7 @@ type Failed = bool;
pub struct Basic<
World,
F = WhichScenarioFn,
R = RetryOptionsFn,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilslv maybe we could just Box<dyn FnMut> here instead of introducing yet another type parameter? Doesn't seem to be critical.


let at =
rest.strip_prefix(".after").and_then(|after| {
after.strip_prefix('(').and_then(|after| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilslv would be nice to refactor tags parsing into a separate function on RetryOptions, and so cover it with unit tests.

@ilslv ilslv requested a review from tyranron August 30, 2022 10:30
@@ -55,7 +63,7 @@ impl Stats {
/// [`Step`]: gherkin::Step
#[must_use]
pub const fn total(&self) -> usize {
self.passed + self.skipped + self.failed
self.passed + self.skipped + self.failed + self.retried
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilslv I'm unsure that total should count retried scenarios, which are already part of passed or failed ones. This way we will lie about actual count of steps.

@tyranron tyranron merged commit c1d919a into main Sep 8, 2022
@tyranron tyranron deleted the retry-failed-tests branch September 8, 2022 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix semver::breaking Represents breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replay failed tests
2 participants