官方文档
http://allure.qatools.ru/
https://docs.qameta.io/allure/#
Allure框架介绍
灵活的、轻量级的测试报告工具
支持多平台:windows、mac、linux
支持多语言:java、python、PHP、ruby
提供详尽的测试报告、测试步骤、日志
可与jenkins集成
安装
windows:
-
https://github.com/allure-framework/allure2/releases下载allure2.7.zip包
-
解压->进入bin目录->运行allure.bat
-
把bin目录加入PATH环境变量
mac:
brew install allure
我们使用python语言,还需要安装allure-pytest,安装命令:pip install allure-pytest
运行
第一步:生成测试结果数据,并保存在指定目录
pytest [测试文件] --alluredir=./result/
第二步:生成html格式的测试报告(有2种方式)
-
方式1:在线查看报告,直接打开默认浏览器
allure serve ./result/
-
方式2:在本地生成报告,并启动一个tomcat服务(有2个命令)
allure generate ./result/ -o ./report/ --clean
(注:覆盖路径加–clean)
allure open -h 127.0.0.1 -p 8883 ./report/
添加描述
我们希望在测试报告中添加文字描述,使我们的报告更加直观,比如测试的功能模块、子功能名称、测试步骤、测试附加信息等,此时会用到allure的feature、story、step、attach装饰器
test_allure.py
import pytest
import allure
@allure.feature("登录模块")
class TestLogin:
@allure.story("登录成功")
def test_login_success(self):
print("登录成功")
@allure.story("登录失败")
def test_login_fail(self):
print("登录失败")
@allure.story("密码缺失")