• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Pytest问题笔记

武飞扬头像
测试小白Go
帮助1

收集测试用例命令
linux:pytest --collect-only|grep collected
windows:pytest --collect-only|findstr collected

pytest常用参数
pytest -h
查看所有参数的说明
-s:输出调试信息,包括print打印的信息。
-v: 显示更详细的信息
-m: 执行被@pytest.mark.标签名 标记的用例
–reruns=num 失败用例重跑num次。需要安装pytest-rerunfailures插件模块
-q 简化输出信息

pytest.ini 文件配置
#测试用例收集规则
testpaths = apicase #指定用例搜索目录
python_files = test_.py _test.py # 文件名
python_classes = Test
# 类
python_functions = test_
# 函数

addopts = -v --rerun=2 --count=2 #执行pytest时附加参数

log_cli = True # 开启控制台日志显示
log_cli_level = INFO # 控制台日志级别
log__cli_format = %(asctime)s %(levelname)s %(message)s
log__cli_date_format = %Y-%m-%d %H:%M:%S
log_file = ./logs/20211023_1027.log # 输出日志文件名
log_file_level = DEBUG # 输出日志记录级别
log_file_format = %(asctime)s %(levelname)s %(message)s
log_file_date_format = %Y-%m-%d %H:%M:%S

指定mark标签

markers =
smoke: this is smoke case
login: this is login case

allure-基本参数说明
学新通

allure.title 和 allure.description两种用法
可以在方法前通过装饰器@allure.title(“用例标题”)
也可以在方法里面通过allure.dynamic.title(“用例标题”)
两种方法区别,在用例参数化的时候通过第二种方式好集成

allure 日志集成 [0ms 问题和日志告警信息关闭

关闭告警信息,关闭颜色,allure报告中中log打印的信息不会有[0ms

addopts = -p no:warnings --color=no

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgcefbc
系列文章
更多 icon
同类精品
更多 icon
继续加载