当前位置:网站首页>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
测试报告就生成成功了
边栏推荐
- Anta and Huawei Sports Health jointly verify the champion running shoes and lead Chinese sports with innovation
- 海康设备获取YV12图像-不用rtsp
- gin's middleware and routing grouping
- 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)
- FFmpeg多媒体文件处理(ffmpeg操作目录及list的实现)
- 问题系列-如何修改或更新localhost里的值
- 行程和用户[阅读理解法]
- FFmpeg multimedia file processing (FFMPEG logging system)
- Professor Chen Qiang's "Machine Learning and R Application" course Chapter 14 Assignment
- 蓝桥历届真题-既约分数
猜你喜欢
Final assignment of R language data analysis in a university
IDEA Gradle 常遇问题(一)
行程和用户[阅读理解法]
客户端连接rtsp的步骤
面试攻略系列(二)-- 秒杀系统
gin的中间件和路由分组
error Trailing spaces not allowed no-trailing-spaces 9:14 error Unexpected trailing comma
RTSP协议讲解
The sword refers to the offer, cuts the rope 2
Explanation of RTSP protocol
随机推荐
微服务+微信小程序实现社区服务
gin的中间件和路由分组
Q_06_05 文件结构
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面(循环不变量)
X264性能优化
剑指 Offer 56 - II. 数组中数字出现的次数 II(位运算)
Sandbox中的进程/线程相关-1
5G China unicom AP:B SMS ASCII Transcoding Requirements
【奖励公示】第23期 2022年7月奖励名单公示:社区明星评选 | 新人奖 | 博客同步 | 推荐奖
FFmpeg长时间无响应的解决方法
FFmpeg多媒体文件处理(FFMPEG日志系统)
记录本项目中用到的系统调用与C库函数-2
【瑞吉外卖】day05:增、删、改、查分类以及公共字段自动填充
RTSP协议讲解
NC192 二叉树的后序遍历
行程和用户[阅读理解法]
ArcEngine(十)创建矢量图层
音视频录入的pts和dts问题
自己做了个nodejs+epxress+mysql的小项目,怎么才能让别人通过互联网访问呢?
19、学习MySQL 索引