当前位置:网站首页>pytest 之 重运行机制与测试报告
pytest 之 重运行机制与测试报告
2022-08-09 13:06:00 【沉觞流年】
重运行机制
pytest提供了失败重试机制
如果用例运行失败,可以指定运行失败的用例重新运行的次数,例如指定运行失败的用例再次运行两次。但是如果再运行两次还是失败,这个运行失败的用例不会再重新运行。
插件名称:rerunfailures
插件安装
pip install pytest-rerunfailures
使用方式
命令行参数形式
命令:pytest --reruns 重试次数
pytest --reruns 2
表示:运行失败的用例可以重新运行2次。
命令:pytest --reruns 重试次数 --reruns-delay 次数之间的延时设置(单位:秒)
Pytest --reruns 2 --reruns-delay 5
表示失败的用例可以重新运行2次。第一次和第二次的间隔时间为5秒钟。
pycharm编辑器方式
添加参数 -s -v --reruns 2 --reruns-delay 5
如果运行失败的用例,会再运行(RERUN)两次
测试报告
pytest可以生成多种样式的结果
JunitXML 格式
生成JunitXML 格式的测试报告
命令:
pytest --junitxml=path
这种测试报告其实也会遇到,XML格式文件,记录了用例运行的流程,如果是一些测试开发,或者要对测试报告的内容再次进行拓展的,这种格式的测试报告就派的上用处。相当于一个中转的作用
txt格式
生成result log格式的测试报告
命令:
pytest --resultlog=report\log.txt
Html格式
生成Html格式的测试报告需要先安装html报告的插件
pip install pytest-html
生成Html格式的测试报告
命令行形式
pytest --html=(相对路径)
py文件形式
首先,在项目根目录下新建 run.py 和 pytest.ini 文件
pytest.ini
[pytest]
markers =
demo : just for display
给用例打上标记,然后编辑run.py
run.py
import pytest
pytest.main(["-s","-v","-m","demo","--html=Outputs/report.html","--reruns","2","--reruns-delay","5"])
运行run.py

测试报告最终是这个样子的,还是过于简单,allure报告会比较全面
边栏推荐
- JS本地存储 sessionStorage和localStorage
- Q_06_05 文件结构
- 为什么文字不贴合边
- GIN中GET POST PUT DELETE请求
- Q_07 词汇表
- javscript基础易错点集合
- Draw a histogram with plot_hist_numeric()
- Realization of RTSP Protocol
- Professor Chen Qiang the machine learning and R application course chapter 18 assignments
- Unicom network management protocol block diagram
猜你喜欢

eslint语法规则报错

How to solve the 0x80070005 error when the computer is reinstalled and the system is restored

GIN a preliminary study, the environment is installed

Uni - app - uview Swiper shuffling figure component, click on the links to jump (click to get the item after the row data, remove data operation)

error Trailing spaces not allowed no-trailing-spaces 9:14 error Unexpected trailing comma

蓝桥历届真题-跑步锻炼

01_iTween_第一天--小球抛物线

5G China unicom repeater network management protocol real-time requirements

puzzle(016.5)逻辑电路
![[MRCTF2020]套娃-1](/img/cb/ba780a4929acd9d76f77ab269faff6.png)
[MRCTF2020]套娃-1
随机推荐
LeetCode 37. Solve Sudoku
为什么文字不贴合边
Dry+Bean+Dataset R语言数据分析,报告英文
FFmpeg av_interleaved_write_frame错误
Process/Thread related in Sandbox - 1
WPF 系统托盘 图标闪烁
现在40系显卡都快出来了,为何1060型号的显卡还有这么多人用?
Map mixed density function and quantile added line
gin's middleware and routing grouping
Professor Chen Qiang's "Machine Learning and R Application" course Chapter 15 Homework
render解析
FFmpeg多媒体文件处理(ffmpeg操作目录及list的实现)
gin的中间件和路由分组
陈强教授《机器学习及R应用》课程 第十三章作业
Unity3d_API_Gyroscope 陀螺仪的接口
CPU-MIPS32 instruction architecture (unlocked pipeline microprocessor)
【NVIDIA】Tesla V100安装NVIDIA-Driver驱动程序适配CUDA-Toolkit-11.6
Q_04_04 Q#类型模型
面试攻略系列(四)-- 你不知道的大厂面试
2.微服务'黑话'集锦及Eureka注册中心相关概念