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

Rerun all tests if any test fails #228

Open
dron4ik86 opened this issue Jul 17, 2023 · 0 comments
Open

Rerun all tests if any test fails #228

dron4ik86 opened this issue Jul 17, 2023 · 0 comments

Comments

@dron4ik86
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant