pytest-allure框架简单封装----测试报告

安装allure-commandline---可以支持allure命令

把对应的压缩包解压后,把xxx/bin配置到环境变量的path去

可以输入allure -version检查版本

pip install allure-pytest==2.11.1

生成测试报告

import pytest

pytest_args = ["-s","-v","--capture=sys", #用于显示输出调试信息,设置级别,打开实时输出

"--clean-alluredir",#清空alluredir中的历史数据

"--alluredir=allure-results"#执行过程的数据存放到allure-results中区

]

print("run pytest:",pytest_args)

print.main(pytest_args)

生成测试报告allure-html

allure命令只能通过控制台运行,要用os调用控制台

os.system("allure generate -c -o allure-report")#前面部分是固定的,allure-report是名字,可以自己取

生成测试报告,双击直接打开查看

allure报告必须以服务形式打开,你直接进入到目录是无法打开(没有数据)

from allure-combine import combine_allure

#combine_allure(测试报告路径)

combine_allure("./allure-report")

可以加一个装饰器添加标题,with allure step添加步骤

@allure.title("用例标题") 来给测试报告分步骤

@allure.title("这是登录用例")

def test_login():

with allure step("第一步"):

相关推荐
久久学姐7 天前
Python+Playwright+Pytest+BDD,用FSM打造高效测试框架
python·pytest·bdd·playwright·fsm
小白上线*^_^*7 天前
Pytest 自动化测试框架速通指南(二)
软件测试·pytest·python测试框架·ai测试基础
Logintern098 天前
pytest的AST 断言重写
pytest
Tinyfacture9 天前
接口自动化之添加商品(pytest)
python·测试工具·自动化·pytest
ji_shuke11 天前
从零深入:基于 Playwright + Pytest + Allure 的企业级 Web 端到端自动化测试框架实战
前端·自动化测试·docker·jenkins·pytest·allure·playwright
祉猷并茂,雯华若锦12 天前
Selenium+Pytest自动化测试框架实战
selenium·测试工具·pytest
祉猷并茂,雯华若锦13 天前
Pytest+Selenium自动化测试:失败自动截图集成Allure报告
selenium·测试工具·pytest
我的xiaodoujiao16 天前
API 接口自动化测试详细图文教程学习系列32--Allure测试报告2
python·学习·测试工具·pytest
一孤程20 天前
Pytest+Selenium搭建自动化框架-保姆级实战教程
selenium·自动化·pytest
名字还没想好☜24 天前
用 pytest fixture 组织可维护的测试:告别一堆重复的 setUp
数据库·python·oracle·pytest·测试