当前位置:网站首页>pytest+allure生成测试报告
pytest+allure生成测试报告
2022-07-29 09:26:00 【测试小鬼】
前言
Allure Framework是一种灵活的轻量级多语言测试报告工具,不仅可以以简洁的网络报告形式非常简洁地显示已测试的内容,而且还允许参与开发过程的每个人从日常执行中提取最大程度的有用信息。
一、安装
使用pip安装pytest和allure-pytest,加上--index-url地址,下载会快一些
pip install pytest==4.5.0 --index-url https://pypi.douban.com/simple
pip install allure-pytest==2.8.6 --index-url https://pypi.douban.com/simpleallure是一个命令行工具,需要去github上下载最新版 Releases · allure-framework/allure2 · GitHub

下载完成之后,解压到本地电脑

把bin目录添加到环境变量Path下

三、使用说明
@allure.feature # 用于定义被测试的功能,被测产品的需求点
@allure.story # 用于定义被测功能的用户场景,即子功能点
with allure.step # 用于将一个测试用例,分成几个步骤在报告中输出
allure.attach # 用于向测试报告中输入一些附加的信息,通常是一些测试数据信息
@pytest.allure.step # 用于将一些通用的函数作为测试步骤输出到报告,调用此函数的地方会向报告中输出步骤
四、示例
import allure
import pytest
@allure.step("步骤1:点xxx")
def step_1():
print("111")
@allure.step("步骤2:点xxx")
def step_2():
print("222")
@allure.feature("编辑页面")
class TestEditPage():
'''编辑页面'''
@allure.story("这是一个xxx的用例")
def test_1(self, login):
'''用例描述:先登录,再去执行xxx'''
step_1()
step_2()
print("xxx")
@allure.story("打开a页面")
def test_2(self, login):
'''用例描述:先登录,再去执行yyy'''
print("yyy")cd到test_allure_demo.py所在的目录文件,命令行执行
pytest --alluredir ./report/allure_raw
执行完成后,在当前目录下生成report目录,report目录下生成一个allure_raw的目录,这里存放了测试报告的JSON格式原始文件,不能打开成html的报告

启动allure报告服务,输入生成的IP地址和端口即可访问
| allure serve report/allure_raw |

5|0Jenkins + allure生成报告
安装插件

安装后选择重启
安装完成后打开jenkins首页-系统管理-全局工具配置-Allure Commandline, 安装 allure 命令行工具
构建运行命令
cd C:\Users\Administrator\Desktop\learn\py23\chongshi\pycs
pytest C:\Users\Administrator\Desktop\learn\py23\chongshi\pycs\test_allure_demo.py --alluredir ${WORKSPACE}/allure_raw/


最后在我的QQ技术交流群里整理了我这10几年软件测试生涯整理的一些技术资料,包括:电子书,简历模块,各种工作模板,面试宝典,自学项目等。如果在学习或工作中遇到问题,群里也会有大神帮忙解答,群号 798478386 ( 备注CSDN555 )
全套软件测试自动化测试教学视频

300G教程资料下载【视频教程+PPT+项目源码】

全套软件测试自动化测试大厂面经

边栏推荐
- 网络安全(6)
- 1.2.24 fastjson deserialization templatesimpl uses chain analysis (very detailed)
- Discussion on the integration of storage and calculation and the calculation in storage
- 文件上传及拓展
- 附录2-一些简单的练习
- Study and exploration of Redux API implementation of Redux
- 机器学习之分类模型评估指标及sklearn代码实现
- View port occupancy
- Unity guidance system. Click the target object and prompt the text to change color to enter the next step
- 【云驻共创】【HCSD大咖直播】亲授大厂面试秘诀
猜你喜欢

Cloud native management practice: business led Devops continuous delivery system

(视频+图文)机器学习入门系列-第1章 引言

Configuration file settings for remote connection to Windows version server redis

Retinal Vessel Segmentation via a Semantics and Multi-Scale Aggregation Network

Four types of technical solutions shared by distributed sessions, and their advantages and disadvantages

【机器学习】逻辑回归代码练习

On the charm of code language
![[machine learning] logistic regression code exercise](/img/dc/203f240e2eb213dbd6173d17e47ec6.jpg)
[machine learning] logistic regression code exercise

Appendix 2 – some simple exercises

Floweable advanced
随机推荐
STM32 application development practice tutorial: getting to know STM32 for the first time
201803-3 CCF URL映射 满分题解
Summary of introduction to unityshader (2): Beginner Level
机器学习之分类模型评估指标及sklearn代码实现
用户身份标识与账号体系实践
当 update 修改数据与原数据相同时会被更新吗?
ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)
How does xjson implement four operations?
Flutter文本编辑器
Flowable 高级篇
How to export the old and new file names and locations to excel after file renaming
MySQL的数据类型
STM32 application development practice tutorial: design and implementation of controllable LED water lamp
How to contribute to openharmony
Handwritten character recognition
Use cpolar to publish raspberry pie web pages (improvement of cpolar function)
Four types of technical solutions shared by distributed sessions, and their advantages and disadvantages
Unity 引导系统.点击目标物体后提示文字变色进入下一步
Pyqt5 rapid development and practice 6.5 qgridlayout (grid layout)
The gold content of PMP certificate has been increased again and included in the scope of Beijing work residence permit