Allure自动化测试报告之修改allure测试报告logo与标题,让报告具有公司的气息
生活随笔
收集整理的這篇文章主要介紹了
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-plugin4、進入
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_pathdict = {} # 用來存儲數據class JsonAlter():# 獲取json里面數據def get_json_data(self, name):# 定義為只讀模型,并定義名稱為fwith open(f'{project_path}/content/report/html/widgets/summary.json', 'rb') as f:# 加載json文件中的內容給paramsparams = json.load(f)# 修改內容params['reportName'] = name# 將修改后的內容保存在dict中dict = params# 關閉json讀模式f.close()# 返回dict字典內容return dict# 寫入json文件def write_json_data(self, dict):# 定義為寫模式,名稱定義為rwith 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、保存,運行測試腳本,查看報告
總結
以上是生活随笔為你收集整理的Allure自动化测试报告之修改allure测试报告logo与标题,让报告具有公司的气息的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 视频录制——SurfaceView +
- 下一篇: HTTP 401和403区别