pytes集成allure生成测试报告

前言

allure是一款轻量级并且非常灵活的开源测试报告框架。它支持绝大多数测试框架, 例如TestNG、Pytest、JUint等。它简单易用,易于集成。下面就Pytest如何与Allure集成做详细介绍。

Allure安装

1、Allure安装包下载地址:https://github.com/allure-framework/allure2/releases

2、下载后解压安装包,配置Path环境变量。进入解压后的Allure/bin目录,将此路径设置在系统环境变量Path下。相关图片如下:

 3、检查是否配置成功,如图在命令行输入: allure --version

 Allure集成

1、安装插件:pip install allure-pytest

2、基于pytest的测试用例,可这样使用

@allure.feature # 用于描述被测试产品需求

@allure.story # 用于描述feature的用户场景,即测试需求

with allure.step # 用于描述测试步骤,将会输出到报告中

allure.attach # 用于向测试报告中输入一些附加的信息,通常是一些测试数据,截图

3、配置运行参数,指定测试报告数据路径,如图

 4、运行用例后,就会输出测试报告数据到allure-outs,基于测试数据生成测试报告

allure generate ./allure-outpus/ -o ./allure-report/ --clean

 5、打开测试报告路径下的index.html 即可看到完整报告

posted @ 2022-07-05 17:08  keena_jiao  阅读(78)  评论(0编辑  收藏  举报