前言:pytest 运行用例,如果是本地单个执行,那可以在IDE环境中通过手工点击或者按目录方式执行,但是这种方式都是串行的,实际使用中会有需要并发和重复执行的需求,这里将操作命令梳理下。
依赖安装:
用例并发执行依赖:pip install pytest-xdist
用例重复执行依赖:pip install pytest-repeat
用例基础报告依赖:pip install pytest-html
用例allure报告依赖:pip install allure-pytest (allure配置手册)
命 令:pytest -v -n 4 --html=report.html test_fund_list_detail_check.py -s --count=3
命令解释:
- -v -n 4 表示 开启4个进程来执行用例;
- --html=report.html 表示用例执行报告输出到report.html
- test_fund_list_detail_check.py 当前目录下的用例文件

本文介绍了如何使用pytest进行用例并发执行、重复执行以及生成执行报告。依赖安装包括pytest-xdist、pytest-repeat、pytest-html和allure-pytest。具体命令如:pytest -v -n 4 --html=report.html test_fund_list_detail_check.py -s --count=3,用于开启4个进程,重复执行3次,并生成HTML报告。另外,还展示了如何生成Allure报告。

1050

被折叠的 条评论
为什么被折叠?



