2

Say if Appium throws a webdriver exception error, only then that specific test should rerun in pytest.

2
  • pytest --lf will rerun all tests that failed in the previous run (lf = "last failed"). pytest --lf -x will rerun only the first test that has failed in the previous run. If you want to run a specific test, pass its node ID as parameter, e.g. pytest tests/test_module.py::test_func_name. The node IDs of the failed tests are printed in a special section at the end of the output. Commented Nov 27, 2020 at 13:19
  • --lf (an alias of --last-failed) is documented in How to rerun failed tests and maintain state between test runs. See also this answer. Commented 3 hours ago

1 Answer 1

1

Use the pytest-rerunfailures library to achieve this. It is a plugin for pytest.

Following are the requirements to use it.

  • Python 3.6, up to 3.8, or PyPy 3

  • pytest 5.0 or newer

Once installed, you can pass --only-rerun argument with pytest and rerun the specific failed test.

pytest --reruns 5 --only-rerun AssertionError
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.