pytest之allure-pytest生成报告

allure-pytest 环境准备

 

mac环境相关:

jdk1.8+

python 3.7版本
pytest 6.1.2版本
allure-pytest   2.8.29 最新版

如果报错:AttributeError: module 'allure' has no attribute 'severity_level'
这个是之前 pytest-allure-adaptor 这个插件与 allure-pytest 不能共存,卸载掉 pytest-allure-adaptor

首先如果你没有安装 pytest 库的话,先使用 pip 安装一下:

pip3 install pytest

另外还需要安装 pytest 支持 allure 报告的插件库:

pip3 install allure-pytest

接下来在运行测试时,使用 pytest 命令运行:

pytest <测试目录> --alluredir <测试报告结果存放目录>

比如,我的文件夹目录如下

 

那么这个命令就应该写为:

pytest tests --alluredir report/allure_raw
  • tests 为测试用例存放目录,告诉 pytest 应该去哪里找用例;
  • report 是存放测试报告的文件目录,allure 收集 pytest 运行后产出的json格式结果放在report下的allure_raw 文件夹中。pytest捕捉到的测试用例,每个用例的执行结果会生成一个json文件

注意:这里的 allure_raw 文件夹只存放的是收集的测试结果,还不是报告!报告还需要调用 allure 命令去生成。

 

我们要生成漂亮的报告还需要一步,从 github(

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值