当前位置:网站首页>pytest 之 allure报告
pytest 之 allure报告
2022-08-09 13:06:00 【沉觞流年】
pytest 之 allure报告
Allure Framework 是一种灵活的轻量级多语言测试报告工具,不仅可以以简洁的Web报告形式非常简洁地显示已测试的内容,而且还允许参与开发过程的每个人从日常执行中提取最大程度的有用信息。测试
左侧给出了 allure 报告支持的语言和框架,点击对应的链接可了解相应的使用方法
安装allure
文档开头,给出了三种不同的操作系统的安装方式
还有通用方法,三种操作系统都可以通过该种方式进行安装
这里介绍的是采用通用方法在 Windows 下安装 allure
1、下载 allure.zip
点击文档上的链接,注意,要把请求方式换成 https。链接
选择最新的包下载
选择 zip 格式
这里也提供了github下载链接
2、解压到本地目录后配置环境变量
下载完成后,将文件进行解压,存放路径看个人,怎么方便怎么来
解压完成后,bin 目录下有两个文件,就是用来启动allure测试报告用的,Windows 下点击bat文件即可
为了能在命令行输入命令进行使用,需要配置allure.bat的环境变量
在命令行中运行allure,确认环境变量配置成功。
使用快捷键Win + R,输入 cmd ,打开黑屏终端,,输入命令 allure ,可以看到各种选项,说明环境变量配置成功
与 pytest 集成
与 pytest 集成,需要 pytest 执行用例后,生成 allure 能够解析的测试结果文件
1、安装 allure-pytest 插件
使用命令安装 allure-pytest 插件
pip install allure-pytest
2、生成 allure 报告
1. 通过命令生成 allure 能够解析的测试结果文件
pytest --alluredir=/tmp/my_allure_results
/tmp/my_allure_results 为测试报告文件所在路径
该命令的参数可以和运行测试用例的参数一起执行
这里就不通过命令行的方式生成对应的文件,而是通过 run.py 的方式执行
run.py
import pytest
pytest.main(["-s","-v","-m","demo","--html=Outputs/reports/report.html","--reruns","2","--reruns-delay","5","--alluredir=Outputs/allure_reports"])
运行 run.py 文件后,可以看到,allure_reports 目录下生成了一堆测试结果文件,里面记录的都是关于测试用例的执行情况
可以优化一下,按日期生成文件
import pytest
from Common import logger
html_report = "Outputs/reports/report_{}_test.html".format(logger.curTime)
allure_report_dir = "Outputs/reports/allure_report_{}".format(logger.curTime)
pytest.main(["-s","-v","-m","demo","--html={}".format(html_report),"--reruns","2","--reruns-delay","5","--alluredir={}".format(allure_report_dir)])
2. 生成 allure 测试报告
进入项目根目录下,输入命令
allure serve /tmp/my_allure_results
这里测试报告文件所在路径为 Outputs/allure_reports,所以我的命令为
allure serve Outputs/allure_reports

生成成功后,如果没有自动弹出测试报告,可以点击链接,打开测试报告文件
allure测试报告就生成成功了
边栏推荐
- The FPGA - work summary recently
- 昇腾AI开发者创享日南京站!一起CANN机器狗+AI机械臂实现硬核智慧救援!燃爆现场~
- Jenkins API groovy calling practice: Jenkins Core Api & Job DSL to create a project
- Professor Chen Qiang the machine learning and R application course chapter 18 assignments
- NC15 求二叉树的层序遍历
- 力扣解法汇总1413-逐步求和得到正数的最小值
- 海康设备获取YV12图像-不用rtsp
- 七夕力扣刷不停,343. 整数拆分(剑指 Offer 14- I. 剪绳子、剑指 Offer 14- II. 剪绳子 II)
- The sword refers to Offer 56 - II. Number of occurrences of a number in an array II (bit operation)
- 微服务+微信小程序实现社区服务
猜你喜欢

Periodic sharing of Alibaba Da Tao system model governance

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

Jenkins API groovy calling practice: Jenkins Core Api & Job DSL to create a project

Come and throw eggs.

GIN中GET POST PUT DELETE请求

FFmpeg相机花屏花图问题解决方法

海康设备获取YV12图像-不用rtsp

TCP三次握手和四次挥手及拥塞控制

Unity3d_API_Gyroscope 陀螺仪的接口

Q_04_05 使用Qubits
随机推荐
IDEA Gradle 常遇问题(一)
剑指 Offer 57 - II. 和为s的连续正数序列(滑动窗口)
FFmpeg相机花屏花图问题解决方法
剑指offer,剪绳子2
陈强教授《机器学习及R应用》课程 第十四章作业
ArcEngine(九)图形绘制
缓存和数据库一致性问题
RTSP协议的实现
The sword refers to the offer, cuts the rope 2
NC192 二叉树的后序遍历
GIN文件上传与返回
行程和用户[阅读理解法]
Q_06_02 类型模型
Unity3d_API_Gyroscope 陀螺仪的接口
现在40系显卡都快出来了,为何1060型号的显卡还有这么多人用?
vim常用命令
NC193 二叉树的前序遍历
关于做2D游戏时,Canvas边界显示在Game窗口的问题
ArcEngine(十)创建矢量图层
Q_06_01 Q#编程语言