当前位置:网站首页>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
测试报告就生成成功了
边栏推荐
- FFmpeg multimedia file processing (FFMPEG logging system)
- 力扣解法汇总1413-逐步求和得到正数的最小值
- GIN a preliminary study, the environment is installed
- 陈强教授《机器学习及R应用》课程 第十三章作业
- 微服务+微信小程序实现社区服务
- RTSP协议的实现
- 面试攻略系列(四)-- 你不知道的大厂面试
- Record the system calls and C library functions used in this project-2
- GET POST PUT DELETE request in GIN
- 剑指 Offer 57 - II. 和为s的连续正数序列(滑动窗口)
猜你喜欢
随机推荐
某高校的R语言数据分析期末作业
Professor Chen Qiang "application in machine learning and R" course chapter 17
NC61 两数之和
FFmpeg多媒体文件处理(ffmpeg打印音视频Meta信息)
telnet+ftp to control and upgrade the device
缓存和数据库一致性问题
FFmpeg多媒体文件处理(ffmpeg操作目录及list的实现)
关于做2D游戏时,Canvas边界显示在Game窗口的问题
利用信号灯和共享内存实现进程间同步通信
Professor Chen Qiang's "Machine Learning and R Application" course Chapter 13 Assignment
Draw a histogram with plot_hist_numeric()
01_iTween_第一天--小球抛物线
JS轮播图实现
搭建大型分布式服务(二)搭建会员服务
【NVIDIA】Tesla V100安装NVIDIA-Driver驱动程序适配CUDA-Toolkit-11.6
Unity3d_API_GPS_LocationService
An Offer 21. Adjust the array in order to make odd in even the front (loop invariant)
CPU-MIPS32 instruction architecture (unlocked pipeline microprocessor)
NC7 买卖股票的最好时机(一)
JS本地存储 sessionStorage和localStorage