Pytest 参数参考

  1.  -vs  表示既输出调试信息同时输出执行详细信息  : pytest -vs ./pytest_1
  2. -n   支持多线程或者分布式运行测试用例
  3. --reruns   失败用例重跑   : pytest -vs ./pytest_1/test_login.py --reruns 2
  4. -x   只要存在失败用例则停止执行  : pytest -vs ./pytest_1/test_login.py -x
  5. --maxfail   只要存在max个失败用例则停止执行 :pytest -vs ./pytest_1/test_login.py --maxfail 2
  6.  -k   根据测试用例的部分字符串执行用例  :  pytest -vs ./pytest_1/test_login.py -k "oo"
  7.  --html 生成测试报告  : pytest --html ./reports/report.html
  8. -s    表示输出调试信息,包括print打印信息 :
  9. -v   表示输出用例执行详细信息
  10. -k 运行匹配给定子字符串表达式的类、方法、function :

            pytest -k "dir" 可运行dir目录下的用例

           pytest -k "dir2" 无法获取dir2目录下的用例

11.     --collect-only  只收集测试用例不运行 :pytest --collect-only

12.     --tb=no  简洁打印输出结果   ---- 好像也不怎么简洁

           pytest --tb=no

          其他输入类型 print mode (auto/long/short/line/native/no)

13.     -m  只运行匹配给定标记表达式的测试

           需要 import pytest,pytest.mark.关键字

           pytest -m run_these --tb=no

            只会运行 test_passing2、 test_passing3

14.      pytest -l  or –showlocals  运行失败打印变量的值   -- 所以这是lmn的l

15.      pytest --version   显示版本

16.      --lf  (last fail)  缓存,只运行上次执行错误的用例

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值