当前位置:网站首页>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+项目源码】

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

边栏推荐
- Summary of introduction to unityshader (2): Beginner Level
- Webassembly 2022 questionnaire results are fresh
- Safety is no longer the only selling point. Test drive "slash youth" Volvo C40
- Emmet syntax
- Vs2015 uses loadlibrary to call DLL library
- No swagger, what do I use?
- Briefly describe the difference between heap and stack
- How does alternates achieve high-performance publish and subscribe?
- [苹果开发者账号]06 转让开发者账号后,开发者年费自动续费问题
- Configuration file settings for remote connection to Windows version server redis
猜你喜欢

How does alternates achieve high-performance publish and subscribe?

Pyqt5 rapid development and practice 6.5 qgridlayout (grid layout)

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

文件重命名后,怎样将新旧文件名及所在位置导出到excel
![[machine learning] logistic regression code exercise](/img/dc/203f240e2eb213dbd6173d17e47ec6.jpg)
[machine learning] logistic regression code exercise

OpenCV入门基础学习

《UnityShader入门精要》总结(2):初级篇

Flowable 基础篇2

A structured random inactivation UNET for retinal vascular segmentation

高智伟:数据管理赋能交通行业数字化转型
随机推荐
【集中培训】HCIP-Cloud Computing 资源交流帖
Unity xchart3.0 basic usage quick start
网络原理笔记(五层网络)
First order traversal / second order traversal determines the approximate shape of the tree
Solve the problem of reading data garbled by redis visualization tool
[unity entry program] collection of common learning websites
The gold content of PMP certificate has been increased again and included in the scope of Beijing work residence permit
Summary of research on endogenous information security technology of industrial measurement and control equipment
Safety is no longer the only selling point. Test drive "slash youth" Volvo C40
One click automated data analysis! Come and have a look at these treasure tool libraries
Will the modified data be updated when it is the same as the original data?
[Bert multi label text classification practice] I - overview of practical projects
乱打日志的男孩运气怎么样我不知道,加班肯定很多
使用cpolar发布树莓派网页(cpolar隧道的完善)
附录2-一些简单的练习
Could not receive a message from the daemon
基于ArkUI eTS开发的坚果新闻(NutNews)
先序遍历/后序遍历确定树的大致形态
[performance optimization methodology series] III. core idea of performance optimization (2)
C# 使用RestSharp库实现POST请求