参考博客:
pytest(5)多进程并行执行用例_redrose2100的博客-CSDN博客_pytest并发执行
背景:
ui用例太多,多进程执行case,节约时间。
介绍:
依赖pytest-xdist插件
pip install pytest-xdist
方式一:
使用 pytest -n auto 默认自动检查系统cpu个数,然后进行并发
pytest -n auto
方式二:
指定并发数 pytest -n 2 即并发数2执行
pytest -n 2
集成allure报告:
执行方式一:
pytest.main(["-s", "-v", "-m", "cs1", "--html=Outputs/pytest_report/pytest.html", "--alluredir=Outputs/allure_report","-n","2"])
执行方式二:
pytest.main(["-s", "-v", "-m", "cs1", "--html=Outputs/pytest_report/pytest.html", "--alluredir=Outputs/allure_report","-n","auto"])