How to re-reun a specific pytest test, based on output error

995 Views Asked by At

Say if appium throws webdriver exception error, only then that specific test should re-run in pytest

1

There are 1 best solutions below

0
On

Use 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 PyPy3

pytest 5.0 or newer

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

$ pytest --reruns 5 --only-rerun AssertionError