当前位置:网站首页>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报告会比较全面
边栏推荐
- Map mixed density function and quantile added line
- TCP三次握手和四次挥手及拥塞控制
- How to reduce the size of desktop icons after the computer is reinstalled
- Final assignment of R language data analysis in a university
- JZ7 重建二叉树
- Sandbox中的进程/线程相关-2
- An Offer 21. Adjust the array in order to make odd in even the front (loop invariant)
- Q_04_06 把它放在一起:传送
- Sandbox中的进程/线程相关-1
- WSA toolkit installed app store tip doesn't work how to solve?
猜你喜欢
随机推荐
万物皆可柯里化的 Ramda.js
Record the system calls and C library functions used in this project-2
剑指 Offer 56 - II. 数组中数字出现的次数 II(位运算)
Come and throw eggs.
陈强教授《机器学习及R应用》课程 第十四章作业
Q_08 更多信息
Professor Chen Qiang "application in machine learning and R" course chapter 17
【瑞吉外卖】day05:增、删、改、查分类以及公共字段自动填充
The sword refers to the offer, cuts the rope 2
Q_06_03 表达式
陈强教授《机器学习及R应用》课程 第十五章作业
FFmpeg multimedia file processing (ffmpeg prints audio and video Meta information)
群组行动控制--自动队列化实现策略
Dry+Bean+Dataset R语言数据分析,报告英文
puzzle(016.5)逻辑电路
Unicom network management protocol block diagram
音视频录入的pts和dts问题
自己做了个nodejs+epxress+mysql的小项目,怎么才能让别人通过互联网访问呢?
Deep Learning Based on R Language - Simple Regression Case
Q_06_04 语句和其他构造