当前位置: 首页 > 图灵资讯 > 行业资讯> python中如何生成allure报告?

python中如何生成allure报告?

发布时间:2025-11-26 20:50:56

我们知道,游戏项目的发布只有在开发人员不断测试后才能上线。测试对开发人员非常重要。那么,如何简单地显示测试内容,并允许开发人员从日常实施中提取有用的信息呢?即使用灵活的轻量级多语言测试报告工具,以简单的在线报告的形式显示。下面,小边将带领您如何在python中生成allure报告。

一、安装pytestttest

pytest是python的第三方单元测试框架,用于生成原始执行结果。

非常方便易用。测试用例可以大规模编写,比较复杂。

pipinstallpytest

二、安装allure-pytest

allure-pytestpython第三方库。用于连接pytestallure,它们可以一起使用。

allure-pytest基于pytest适用于生成原始执行结果allurejson格式结果。json格式结果可用于后续应用allure生成html结果。

pipinstallallure-pytest

三、安装alllure-commandline

该工具是命令行生成allure报告的工具,官方下载链接:https://bintray.com/qameta/generic/allure2

四、allure生成测试报告

1、生成xml文件

pytest 测试文件所在的路径 --alluredir 目录中生成的测试结果数据保存

pytest--alluredir=resport/xml/D:/PyTest/tests/allure/test_allure_demo.py1

2、生成html文件

allure generate 测试结果数据所在目录 -o 保存测试报告的目录 --clean

alluregenerateD:/PyTest/tests/allure/report/xml-oD:/PyTest/tests/allure/report/html--clean1

3、allure生成测试报告

目录中的数据 -o 保存测试报告的目录 --clean

alluregenerateD:/PyTest/tests/allure/report/xml-oD:/PyTest/tests/allure/report/html--clean1

以上是在python中生成allure报告的过程。只需在相应的目录下查看html报告即可。没有想象的那么难吗?如果需要生成简单的测试报告,不妨试试这个方法~

相关文章

python中如何生成allure报告?

python中如何生成allure报告?

2025-11-26
python中seed随机函数如何生成随机数?

python中seed随机函数如何生成随机数?

2025-11-26
python中如何将华氏温度转换为摄氏温度?

python中如何将华氏温度转换为摄氏温度?

2025-11-26
python中如何将九九乘法表输出到txt文件中?

python中如何将九九乘法表输出到txt文件中?

2025-11-25
python中堆排序算法实现

python中堆排序算法实现

2025-11-25
python中pop函数和remove函数的区别有哪些

python中pop函数和remove函数的区别有哪些

2025-11-25