标记用例失败:
1.1、pytest.xfail(reason)标记失败,且后续代码不执行
1.2、pytest.mark.xfail(condition,reason=None)标记预期失败,会执行用例,如果失败,结果会显示xfail;通过会显示xpass
condition=True,默认是True,当condition=True时才会标记失败
condition=False,不会标记用例
pytest前置后置注意事项:
@classmethod
@allure.step("全部用例执行前前置条件")
def setUpClass(cls):
@classmethod
@allure.step("每个用例执行前前置条件")
def setUp(cls):
@classmethod
@allure.step("每个用例执行后置条件")
def tearDown(cls):
setUpClass、setUp、tearDown和tearDownClass作为前后置条件需要被@classmethod装饰器装饰