前言:我想很多测试童鞋都做接口测试都用上了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、保存,运行测试脚本,查看报告