Skip to content

Rerun all tests if any test fails #228

Description

@dron4ik86

Hi,
I've encountered a situation with my test suite where the tests are interdependent, meaning the outcome of one test can affect subsequent tests. I understand that it's typically best practice to isolate tests, but due to the nature of my test suite, isolating each test is not feasible.
When I use the pytest-rerunfailures plugin, it only reruns the specific test that fails. In my case, however, if one test fails, I need all tests to be rerun because the failed test could influence the outcomes of the others.
Therefore, I'd like to propose a new feature or option for the plugin: an option to rerun the entire test suite (or a specified group of tests) if any test fails.
For now, my solution to solve this issue is this:

max_retries = 5
retries = 0
while retries < max_retries:
    result = pytest.main(["tests/test_my_tests.py"])
    if result == 0:
        print("Tests passed!")
        break
    else:
        print("Tests failed, rerunning...")
        retries += 1

This feature would provide value for test suites where tests are interdependent and the failure of one test may invalidate the outcomes of the others. I believe this could be a useful addition to the plugin's functionality.

Thank you for considering my proposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions