当前位置:网站首页>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
- FFmpeg av_interleaved_write_frame错误
- glibc memory management model freeing C library memory cache
- [FPGA Tutorial Case 48] Image Case 8 - Realization of Converting RGB Image to HSV Image Based on FPGA, Assisted Verification by MATLAB
- Sandbox中的进程/线程相关-2
- FFmpeg长时间无响应的解决方法
- Explanation of RTSP protocol
- 蓝桥历届真题-既约分数
- CPU-MIPS32 instruction architecture (unlocked pipeline microprocessor)
- render解析
猜你喜欢

Map mixed density function and quantile added line

FFmpeg多媒体文件处理(ffmpeg处理流数据的基本概念)

微服务+微信小程序实现社区服务

关于做2D游戏时,Canvas边界显示在Game窗口的问题

eslint语法规则报错

5G China unicom AP:B SMS ASCII Transcoding Requirements

RTSP协议讲解

七夕力扣刷不停,343. 整数拆分(剑指 Offer 14- I. 剪绳子、剑指 Offer 14- II. 剪绳子 II)

快来扔鸡蛋。

Periodic sharing of Alibaba Da Tao system model governance
随机推荐
面试攻略系列(二)-- 秒杀系统
Periodic sharing of Alibaba Da Tao system model governance
蓝桥杯线上模拟赛——Flex 经典骰子布局
LeetCode 37. Solve Sudoku
Professor Chen Qiang's "Machine Learning and R Application" course Chapter 15 Homework
力扣解法汇总1413-逐步求和得到正数的最小值
GIN a preliminary study, the environment is installed
ArcEngine(九)图形绘制
Professor Chen Qiang's "Machine Learning and R Application" course Chapter 13 Assignment
The sword refers to the offer, cuts the rope 2
FFmpeg多媒体文件处理(FFMPEG日志系统)
NC96 判断一个链表是否为回文结构
NFS pays special attention to the problem of permissions
周末看点回顾|我国IPv6网络全面建成;2022昇腾AI开发者创享日·南京站成功举办…
FFmpeg multimedia file processing (ffmpeg prints audio and video Meta information)
WSA toolkit installed app store tip doesn't work how to solve?
Q_04_06 把它放在一起:传送
PO、DO、TO、VO、DO、DTO、DAO、POJO都是什么?
How to solve the 0x80070005 error when the computer is reinstalled and the system is restored
NC15 求二叉树的层序遍历