Allure自动化测试报告之修改allure测试报告logo与标题,让报告具有公司的气息

前言:我想很多测试童鞋都做接口测试都用上了allure报告吧,那你知道怎么让allure报告具有独特性么?不知道的话看这里吧,叫你修改allure测试报告的logo与标题。

1、安装allure

2、进入

D:\allure-2.13.1\config(D:\allure-2.13.1是自己allure的安装路径)

3、在allure.yml添加

- custom-logo-plugin

如:

plugins:
  - junit-xml-plugin
  - xunit-xml-plugin
  - trx-plugin
  - behaviors-plugin
  - packages-plugin
  - screen-diff-plugin
  - xctest-plugin
  - jira-plugin
  - xray-plugin
  - custom-logo-plugin

4、进入

D:\allure-2.13.1\plugins\custom-logo-plugin\static(D:\allure-2.13.1是自己allure的安装路径)

5、将自己需要展示的logo图片放到这个目录,例如piaoliang.png

6、编辑styles.css(logo-0.png为报告自定义导航栏图标,阿里巴巴为报告自定义导航栏名称)

.side-nav__brand {
  background: url('logo-0.png') no-repeat left center !important;
  margin-left: 10px;
  height: 40px;
  background-size: contain !important;
}
.side-nav__brand span{
	display: none;
}
.side-nav__brand:after{
	content: "阿里巴巴";
	margin-left: 20px;
 
}

注:logo展示样式可自己调试

6、更改allure报告的title名称(报告打开显示的网站名称)

#!/usr/bin/env python
# _*_ coding: utf-8 _*_
# @File :   jsonAlter.py
# @Date :   2020/8/6 15:15 
# @Author : 李文良
import json
from setupMain import project_path


dict = {}  # 用来存储数据


class JsonAlter():
    # 获取json里面数据
    def get_json_data(self, name):
        # 定义为只读模型,并定义名称为f
        with open(f'{project_path}/content/report/html/widgets/summary.json', 'rb') as f:
            # 加载json文件中的内容给params
            params = json.load(f)

            # 修改内容
            params['reportName'] = name

            # 将修改后的内容保存在dict中
            dict = params

        # 关闭json读模式
        f.close()

        # 返回dict字典内容
        return dict

    # 写入json文件
    def write_json_data(self, dict):
        # 定义为写模式,名称定义为r
        with open(f'{project_path}/content/report/html/widgets/summary.json', 'w', encoding="utf-8") as r:
            # 将dict写入名称为r的文件中
            json.dump(dict, r, ensure_ascii=False, indent=4)

        # 关闭json写模式
        r.close()

在这里插入图片描述

7、保存,运行测试脚本,查看报告

  • 4
    点赞
  • 49
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

李先森&Mr.Li

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

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

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

打赏作者

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

抵扣说明:

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

余额充值