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

在 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()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值