allure报告添加环境配置(environment)

4 篇文章 0 订阅
4 篇文章 0 订阅

在 allure 报告首页 ENVIRONMENT 显示 ‘There are no environment variables’ 没有环境变量的配置信息。
环境变量配置可以添加报告相关的配置参数,如运行的系统环境,版本号,测试环境,测试人员等基本信息

environment 配置文件
方法一:environment.properties 文件
在allure的report根目录下添加一个 environment.properties 文件,配置文件不能放置中文,否则会出现乱码

System=MAC
PythonVersion=3.8.5
AllureVersion=2.15.0
BaseUrl=http://xxxxxx:8081/
Project=IAM
author=nan.luo
email=nan.luo@xxxx.com

在运行 pytest 生成 allure 报告的时候,有时候需要加 --clean 参数,清楚之前的报告记录,这样会之前清空 report 目录,environment.properties文件也会被删除。
为了不让 environment.properties 文件删除掉,可以把 environment.properties 文件放项目根目录,在运行报告的时候,先 copy 到 report 目录

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import subprocess

WIN = sys.platform.startswith('win')


def main():
    """

    """
    steps = [
       "venv\\Script\\activate" if WIN else "source venv/bin/activate",
       "pytest  --alluredir allure-results --clean-alluredir",
       "copy environment.properties report\\environment.properties" if WIN else "cp config/environment.properties allure-results/environment.properties",
       "allure generate allure-results -c -o allure-report",
       "allure open allure-report"
    ]

    for step in steps:
        subprocess.run("call " + step if WIN else step, shell=True)


if __name__ == "__main__":
    #  生成pytest-html的日志
    #  pytest --html ../report/report.html --self-contained-html
    main()
  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
回答: 配置allure环境需要以下步骤。首先,下载allure安装包并将其放置在所需的安装目录。然后,配置环境变量,类似于配置Java环境变量,将allure的路径添加到环境变量中。在旧版本中,可以直接使用pytest-allure-adaptor来设置环境信息,如使用from allure import MASTER_HELPER MASTER_HELPER.environment(platform=platform1,version=version,machine=machine,uname=uname)。而在新版本中,需要在allure报告的根目录(通常是项目的reports文件夹)创建environment.properties文件,并填写相应的环境变量信息,例如systemVersion、pythonVersion、allureVersion等。通过这些步骤,可以配置allure环境,并在allure报告首页展示相应的环境信息。123 #### 引用[.reference_title] - *1* [Allure 测试报告环境搭建](https://blog.csdn.net/2301_77645750/article/details/130774494)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] - *2* *3* [allure报告环境配置](https://blog.csdn.net/yuer011/article/details/117674331)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值