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/simple
allure是一个命令行工具,需要去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 |

安装插件

安装后选择重启
安装完成后打开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+项目源码】

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