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("第一步"):

相关推荐
鹿鸣悠悠1 天前
pytest + requests + allure 接口自动化测试框架指南
pytest
忘忧记1 天前
pytest进阶参数化用法
前端·python·pytest
bug_rabbit1 天前
pytest-html 中文乱码问题终极解决方案(Windows版)
windows·html·pytest
庄小法1 天前
pytest
开发语言·python·pytest
工具人55552 天前
pytest练习
pytest
好家伙VCC2 天前
# Pytest发散创新:从基础测试到智能断言的实战进阶指南在现代软
java·python·pytest
小罗和阿泽3 天前
GUI 自动化测试 pywinauto测试框架
开发语言·python·功能测试·测试工具·pytest
文人sec3 天前
抛弃 Postman!用 Pytest+Requests+Allure+Playwright+Minium 搭建高逼格接口+UI自动化测试平台
自动化测试·python·测试工具·ui·pytest·playwright
曲幽4 天前
FastAPI单元测试实战:别等上线被喷才后悔,TestClient用对了真香!
python·单元测试·pytest·api·fastapi·web·httpx·testclient·依赖项覆盖
小罗和阿泽4 天前
接口测试系列 接口自动化测试 pytest框架(四)
pytest