- -vs 表示既输出调试信息同时输出执行详细信息 : pytest -vs ./pytest_1
- -n 支持多线程或者分布式运行测试用例
- --reruns 失败用例重跑 : pytest -vs ./pytest_1/test_login.py --reruns 2
- -x 只要存在失败用例则停止执行 : pytest -vs ./pytest_1/test_login.py -x
- --maxfail 只要存在max个失败用例则停止执行 :pytest -vs ./pytest_1/test_login.py --maxfail 2
- -k 根据测试用例的部分字符串执行用例 : pytest -vs ./pytest_1/test_login.py -k "oo"
- --html 生成测试报告 : pytest --html ./reports/report.html
- -s 表示输出调试信息,包括print打印信息 :
- -v 表示输出用例执行详细信息
- -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) 缓存,只运行上次执行错误的用例