How to re-run Failed Test and set re-tries for python3 py.test

六眼飞鱼酱① 提交于 2019-12-22 08:35:18

问题


I have few web service related test which sends http requests and the response is verified by py.test test cases. I usually get 1 or 2 failures out of 50 tests which are fails due to intermittent slow web server response gathering or due to network.

Is there a way I can re-run or add number of retires to a py.test test case before actually marking it as a Failed one ? Something like run a test 3 times before marking it as failure and moving to the next one, If test passes in any attempt(1 or 2 or in 3) mark it as passed ?


回答1:


flaky describes a possible solution to your problem: https://github.com/box/flaky -- It allows for re-running failed tests once as a default, or up to n times.

You could also try using Looponfail: https://pytest.org/latest/xdist.html. Although it's technically meant to allow for altering a file associated with the failed test, it'll still pause the test you're running after a failure.

Hope this helps.



来源:https://stackoverflow.com/questions/33894691/how-to-re-run-failed-test-and-set-re-tries-for-python3-py-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!