pytest自动化测试常用参数汇总,都帮你总结好了

本文汇总了pytest自动化测试框架的常用参数,如-s用于输出调试信息,-v显示详细执行信息,-n支持多线程或分布式运行,--reruns重跑失败用例,-x和--maxfail控制失败用例的执行,-k按部分字符串筛选用例,以及--html生成测试报告。
摘要由CSDN通过智能技术生成

目录

1. -s 表示输出调试信息,包括print打印信息

2. -v 表示输出用例执行详细信息

3. -vs 表示既输出调试信息同时输出执行详细信息

4. -n 支持多线程或者分布式运行测试用例

5. --reruns 失败用例重跑

6. -x 只要存在失败用例则停止执行

7. --maxfail 只要存在max个失败用例则停止执行

8. -k 根据测试用例的部分字符串执行用例

9. --html 生成测试报告

总结:


1. -s 表示输出调试信息,包括print打印信息

D:\demo>pytest -s ./pytest_1
=============================================================== test session starts ================================================================
platform win32 -- Python 3.7.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: D:\demo
plugins: allure-pytest-2.9.43, forked-1.3.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.0, xdist-2.3.0
collected 1 item                                                                                                                                    

pytest_1\test_login.py 登录1
.

================================================================ 1 passed in 0.07s =================================================================

pytest.main(['-s', './pytest_1/test_login.py'])

2. -v 表示输出用例执行详细信息

D:\demo>pytest -v ./pytest_1
=============================================================== test session starts ================================================================
platform win32 -- Python 3.7.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- d:\program files\python\python37-32\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.4', 'Platform': 'Windows-10-10.0.17763-SP0', 'Packages': {'pytest': '6.2.4', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins'
: {'allure-pytest': '2.9.43', 'forked': '1.3.0', 'html': '3.1.1', 'metadata': '1.11.0', 'ordering': '0.6', 'rerunfailures': '10.0', 'xdist': '2.3.0'}
, 'JAVA_HOME': 'D:\\Program Files\\Java\\jdk1.8.0_221'}
rootdir: D:\demo
plugins: allure-pytest-2.9.43, forked-1.3.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.0, xdist-2.3.0
collected 1 item                                                                                                                                    

pytest_1/test_login.py::TestLogin::test_08_loogin1 PASSED                                                                                     [100%]

================================================================ 1 passed in 0.03s =================================================================

pytest.main(['-v', './pytest_1/test_login.py'])

3. -vs 表示既输出调试信息同时输出执行详细信息

D:\demo>pytest -vs ./pytest_1
=============================================================== test session starts ================================================================
platform win32 -- Python 3.7.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- d:\program files\python\python37-32\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.4', 'Platform': 'Windows-10-10.0.17763-SP0', 'Packages': {'pytest': '6.2.4', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins'
: {'allure-pytest': '2.9.43', 'forked': '1.3.0', 'html': '3.1.1', 'metadata': '1.11.0', 'ordering': '0.6', 'rerunfailures': '10.0', 'xdist': '2.3.0'}
, 'JAVA_HOME': 'D:\\Program Files\\Java\\jdk1.8.0_221'}
rootdir: D:\demo
plugins: allure-pytest-2.9.43, forked-1.3.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.0, xdist-2.3.0
collected 1 item                                                                                                                                    

pytest_1/test_login.py::TestLogin::test_08_loogin1 登录1
PASSED

================================================================ 1 passed in 0.03s =================================================================

pytest.main(['-vs', './pytest_1/test_login.py'])
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值