• 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)  缓存,只运行上次执行错误的用例

  • 相关阅读:
    【HarmonyOS应用开发】三方库(二十)
    向量数据库—加速大模型训练推理
    【面试题精讲】Java包装类缓存机制
    RSA的C++语言描述简单实现
    Vue的MVVM模型
    【c#】线程Monitor.Wait和Monitor.Pulse使用
    利用python写一个可视化的界面
    去中心化身份DID(研究)
    pytorch 学习率衰减策略
    为视觉语言多模态模型进行偏好优化
  • 原文地址:https://blog.csdn.net/yanghaoji/article/details/127635124