Skip to content

Replay failed tests #212

@theredfish

Description

@theredfish

I was wondering if it's something that we can add to the framework. We already have a function to repeat failed tests output but we don't have a function to run failed tests again. It's common to have flaky tests that sometimes can be solved by running them again.

For example :

#[tokio::main]
async fn main() {
    AnimalWorld::cucumber()
        .replay_failed(2)
        .run_and_exit("tests/features/book/output/terminal_repeat_failed.feature")
        .await;
}

Where 2 is the maximum number of times the tests should be run again in case of test failures. Let's say we have the tests A, B, C and D :

  1. During the first run only A passes
  2. Then B, C and D are run again (1 replay left if we have new test failures)
  3. Only B passes, we run again C and D (0 replay left)
  4. D fails again, this one is certainly more than just unstable

Regarding the output we have two choices :

  • Print all test executions : it's transparent but can be repetitive when the tests fail multiple times (like D in this example)
  • Or just print the result once the last replay is done (which can be the maximum, here 2, or a previous run if all tests are passing)

Metadata

Metadata

Assignees

Labels

enhancementImprovement of existing features or bugfix

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions