指定--clean-alluredir参数清空上一次执行记录:

  如果我们想每次执行用例的时候都生成新的测试报告,那么我们可以在命令中加上--clean-alluredir参数。

我们先来看一下跟报告相关的三个参数,命令行中使用pytest -h查看:

 

 

  •  --alluredir=DIR:指定测试报告的生成路径;
  • --clean-alluredir:如果已经存在报告,那就先清空,然后再生成新的测试报告;
  • --allure-no-capture:不添加pytest捕捉的logging/stdout/stderr到测试报告中;

我们加上--clean-alluredir参数重新执行下测试用例:

 

if __name__ == "__main__":
pytest.main(['testlogin.py','-s','--alluredir','../report/tmp'])
os.system('allure generate ../report/tmp -o ../report/report --clean-alluredir')
posted on 2021-10-18 12:28  fxh嘟嘟  阅读(463)  评论(0编辑  收藏  举报