【pytest之allure测试报告使用】

一、安装allure-pytest模块
二、下载转换工具
这个工具主要用来把测试用例的运行结果转换成html格式
去GitHub上下载:https://github.com/allure-framework/allure2/releases
三、下载完成后解压到本地,并把bin目录添加到环境变量
四、运行
pytest test_allure_demo.py --alluredir ./report
–alluredir参数的作用是指出生成的报告文件夹,这里命名为report

五、查看报告
allure serve report

六、装饰器使用方法
在这里插入图片描述

在这里插入图片描述
–allure-severities=SEVERITIES_SET
Comma-separated list of severity names. Tests only
with these severities will be run. Possible values
are: blocker, critical, normal, minor, trivial.
–allure-epics=EPICS_SET
Comma-separated list of epic names. Run tests that
have at least one of the specified feature labels.
–allure-features=FEATURES_SET
Comma-separated list of feature names. Run tests that
have at least one of the specified feature labels.
–allure-stories=STORIES_SET
Comma-separated list of story names. Run tests that
have at least one of the specified story labels.
–allure-link-pattern=LINK_TYPE:LINK_PATTERN
Url pattern for link type. Allows short links in test,
like ‘issue-1’. Text will be formatted to full url
with python str.format().  
选择运行你要执行epic的用例

pytest --alluredir ./report/allure --allure-epics=epic对大Story的一个描述性标签

选择运行你要执行features的用例

pytest --alluredir ./report/allure --allure-features=模块2

选择运行你要执行features的用例

pytest --alluredir ./report/allure --allure-stories=“用户故事:1”

4.生成html报告

方式一

语法:

allure serve allure报告目录

例如:

allure serve Report

运行命令后,会自动在浏览器中弹出allure访问地址,并显示当前执行结果报告

方式二

(推荐)

语法:allure generate report_path -o out_report --clean

例如:

allure generate Report -o Report/html --clean

运行命令后,会在Report/html目录中生成一个html的报告文件

“–clean”: 清空测试报告目录,再生成新的测试报告,不然测试报告不会刷新

4705cb2b01873896383328de180bf202.png

用浏览器打开 index.html 文件,就可以看到酷炫的html报告了

59a70b149adc4f8081613dcea88f2c34.png

下篇文章将分享 Allure 代码实战

相关资源:allure-2.7.0.zip_allure安装包,allure包下载-互联网文档类资源…

转载:https://blog.csdn.net/weixin_42138788/article/details/118299498

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值