How to skip the rest of tests in the class if one has failed?

前端 未结 9 2282
梦毁少年i
梦毁少年i 2020-11-28 06:45

I\'m creating the test cases for web-tests using Jenkins, Python, Selenium2(webdriver) and Py.test frameworks.

So far I\'m organizing my tests in the following str

9条回答
  •  悲哀的现实
    2020-11-28 07:23

    • If you'd like to stop the test execution after N failures anywhere (not in a particular test class) the command line option pytest --maxfail=N is the way to go: https://docs.pytest.org/en/latest/usage.html#stopping-after-the-first-or-n-failures

    • if you instead want to stop a test that is comprised of multiple steps if any of them fails, (and continue executing the other tests) you should put all your steps in a class, and use the @pytest.mark.incremental decorator on that class and edit your conftest.py to include the code shown here https://docs.pytest.org/en/latest/example/simple.html#incremental-testing-test-steps.

提交回复
热议问题