Python接口自动化-Allure

一、安装

Allure下载

1.进入网站,下载

http://allure.qatools.ru/

2、将包解压到任何一个目录。建议不要选C盘或者路径很深的。比如D:\allure-command-2.12.1

3、跳转到解压后的bin目录下面,windows下执行allure.bat。其它平台执行allure.

4、配置allure的环境变量:

image

5、在命令行当中运行allure —version

Allure与pytest的集成

在allure安装完成之后,需要与pytest集成,能够在pytest运行完成之后,生成allure的文件 。

1、安装pytest的allure支撑插件。

pip命令行:

pip install allure-pytest

二、装饰器

https://www.cnblogs.com/poloyy/p/12716659.html

@allure.feature :用于定义被测试的功能,被测产品的需求点

@allure.story : 用于定义被测功能的用户场景,即子功能点

@allure.step :用于将一个测试用例,分成几个步骤在报告中输出

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

image

三、生成测试报告

if __name__ == "__main__":
    # 在./result/report_temp目录下生成测试报告数据
    pytest.main(['--alluredir', './result/report_temp'])
    # 2. /result/report测试报告目录;--clean 清空之前的记录再生成新的报告
    os.system("allure generate './result/report_temp' -o ./result/report --clean")

posted @ 2021-09-13 16:32  难删亦删  阅读(255)  评论(0)    收藏  举报