pytest测试框架中allure定制报告中添加环境配置展示

背景:

allure报告很美观,但是发现在报告中环境经常显示为空没有任何东西,有时候需要在环境上加上一些东西做展示

在这里插入图片描述

第一步:需要先新增一个environment.properties文件,并在文件中添加环境参数,注意不能使用中文

在这里插入图片描述

Author=xxx
BaseUrl=https://baidu.com
ProjectName=FenMiApiFrame
PythonVersion=3.7.0
PytestVersion=7.4.4
AllureVersion=2.18.1

第二步:environment.properties文件需要放再reports下的temp文件

environment.properties文件需要放再reports下的temp文件,但是我们在执行脚本的时候经常会带上./reports/allure --clean参数会清除temp文件,所以需要把environment.properties文件放到根目录,然后再把根目录的environment.properties文件copy到temp文件下,这需要在运行文件增加一行copy代码
在这里插入图片描述

第三步:需要在运行文件上增加一行运行代码

os.system("copy environment.properties  .\\reports\\temp")

在这里插入图片描述

import os
import time
import pytest

if __name__ == '__main__':
    pytest.main()

    time.sleep(1)
    # os.system("allure generate ./reports/temp -o ./reports/allure --clean")
    # copy environment.properties  .\\reports\\temp 设置allure报告环境变量
    os.system("copy environment.properties  .\\reports\\temp")
    os.system("allure generate ./reports/temp -o ./reports/allure --clean")

最后展示效果:

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

CesareCheung

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值