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

相关推荐
qq_5137280415 小时前
为什么选择 pytest 而不是 unittest
pytest
思则变16 小时前
[Pytest][Part 5]单条测试和用例集测试
pytest
杨梅树3 天前
pytest中mark的使用
pytest
测试开发技术5 天前
如何在 Pytest 中调用其他用例返回的接口参数?
面试·自动化·pytest·接口·接口测试·api测试
思则变6 天前
[Pytest][Part 4]多种测试运行方式
pytest
程序员三藏6 天前
如何使用Pytest进行测试?
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·pytest
一个处女座的测试8 天前
Python语言+pytest框架+allure报告+log日志+yaml文件+mysql断言实现接口自动化框架
python·mysql·pytest
思则变11 天前
[Pytest][Part 1]Pytest 自动化测试框架
pytest
思则变12 天前
[Pytest] [Part 2]增加 log功能
开发语言·python·pytest
思则变13 天前
[Pytest][Part 3]检测python package状态
pytest