背景:
我本人不愿意写测试报告,但领导规定每个迭代后都需要发一份测试报告,让我比较难受(不是不会写,主要是测试报告内容比较详实,几乎没有人会细看),没有人看就=流于形式
那么,有没有一种方法,既满足了减轻测试人员的压力,又完成了目标,同时还能整合出一个一目了然的且具有参考意义的测试报告呢?

过程:
首先,因为我们公司使用jira作为迭代管理工具,我想了一下,如果能把jira数据拉下来就好了,于是我去查了一下,发现python是可以对jira进行操作的,那么就可以开整了
我的思路是这样的
1、利用python操作jira获取到我们的预期的数据
2、对数据进行处理,是数据满足我们生成图表的要求
3、使用pychart将处理好的数据变成测试报告的html
4、集成到jenkins上并接受他人的传参,做成千人千面,大家都可以使用的工具

先安装jira和pyecharts

在cmd中运行以下命令
pip install pyecharts
pip install jira

然后新建一个py文件,定义一些操作jira的方法,解析数据的方法,并返回满足生产图片的数据

operationJira.py


from jira import JIRA
class jiraOperation():def loginJira(server,username,password):jira = JIRA(server = server,basic_auth =(username,password))return jira#登录jira并返回一个jira的实例def serchissues(jira,jql,max_results = 50000,fields='components,summary,customfield_10903,labels'):"""serchiuess@:param jql:JQL,str@:param max_results: max results,int,default 100"""try:issues = jira.search_issues(jql,fields=fields, maxResults=max_results)#默认返回指定的三个字段,且最大结果行为50000return issuesexcept Exception as  e:print(e)#根据jql查询jira的信息def analytical(jira_result):summarys = {}components = {}custom_fields = {}reason_bugs = {}for x in jira_result:a = str(x.fields.summary)  #概要if  x.fields.components == []:b = 'None'else:b = str(x.fields.components[0])  #模块 返回的是一个jira的components对象  需要转成strc = str(x.fields.customfield_10903)  #归因分析d = str(x.key)      #jira号e = str(x.fields.labels[0])summarys.setdefault(d,a)    #{jira号:概要}components.setdefault(b,0) #{模块:出现次数}if b in components.keys():components[b] = components[b] + 1custom_fields.setdefault(c,0)  #{归因分析:出现次数}if c in custom_fields.keys():custom_fields[c] = custom_fields[c] + 1reason_bugs.setdefault((d+a),c) #{jira号 jira概要:jira归因分析}labels = ereturn (summarys,components,custom_fields,reason_bugs,labels)#解析jira数据并返回

数据有了,接下来就是根据数据生成图表了

makeChart.py

# -*- coding=utf-8 -*-
from pyecharts.faker import Faker
from pyecharts import options as opts
from pyecharts.charts import Bar, Line,Pie,Tab,Page,Timeline
from pyecharts.components import Table
from pyecharts.options import ComponentTitleOptsclass charts():def make(jira_finail_result):timeline_bar = Timeline().add_schema(is_auto_play=True,pos_top='7.5%',height='2%')timeline_pie = Timeline().add_schema(is_auto_play=True,pos_top='7.5%',height='2%')line_name = []line_data = []for jira_result in jira_finail_result:summarys = jira_result[0]components = jira_result[1]custom_fields = jira_result[2]reason_bugs = jira_result[3]labels = jira_result[4]x = Faker.choose()bar = (Bar().add_xaxis(list(components.keys())).add_yaxis("", list(components.values()))# .reversal_axis() #横向展示.set_global_opts(title_opts=opts.TitleOpts("{}".format(labels)),xaxis_opts=opts.AxisOpts(name_rotate=30, axislabel_opts={"rotate": 30})))timeline_bar.add(bar,'')
#柱状图pie = (Pie().add("2", [list(z) for z in zip(list(custom_fields.keys()), list(custom_fields.values()))],radius=["40%", "70%"],label_opts=opts.LabelOpts(position="outside",formatter="{b}:{c}\n{per|{d}%}",background_color="#eee",border_color="#aaa",border_width=1,border_radius=2,rich={"a": {"color": "#989", "lineHeight": '44%', "align": "center"},"abg": {"backgroundColor": "#e3e3e3","width": "30%","align": "right","height": 21,"borderRadius": [0, 0, 0, 0],},"hr": {"borderColor": "#aaa","width": "71%","borderWidth": 12,"height": 12,},"b": {"fontSize": 15, "lineHeight": 10},"per": {"color": "#eee","backgroundColor": "#324456","padding": [0.5, 0.5],"borderRadius": 1,},},),)# .set_global_opts(title_opts=opts.TitleOpts(title="标题")) #小标题.set_global_opts(legend_opts=opts.LegendOpts(pos_left='83%'),title_opts=opts.TitleOpts(title="{}".format(labels)),tooltip_opts=opts.TooltipOpts(is_show=False, )))timeline_pie.add(pie, "")
#饼图line_name.append(labels)line_data.append(len(summarys))analysetable = (Table().add( ["事件",'详情'],[['需求情况','填写实际的迭代的需求情况'],['bug情况','填写实际的迭代的bug情况'],['总结','对本次发布进行总结']]).set_global_opts(title_opts=ComponentTitleOpts(title="迭代总结")))
#表格bug_list = []for one in reason_bugs:bug_list.append([reason_bugs[one],one])bugtable = (Table()#.add(["bug原因", 'jira号 概要'], [[1, 'sha'], [1, 2]])   # demo样例.add(["bug原因", 'jira号 概要'], bug_list).set_global_opts(title_opts=ComponentTitleOpts(title="Bug归因列表")))
#bug列表清单line = (Line().add_xaxis(line_name,).add_yaxis("迭代测试bug数",line_data, is_smooth=True).set_series_opts(textstyle_opts=opts.TextStyleOpts(font_size=50)).set_global_opts(title_opts=opts.TitleOpts(title="迭代测试bug数"),xaxis_opts=opts.AxisOpts(name_gap=500,name_rotate=30,axislabel_opts={"rotate": 30},)))
#折线图report_name = '测试报告'tab = (Tab().add(analysetable,'迭代总结').add(timeline_bar, '迭代bug功能模块统计').add(timeline_pie,'迭代bug归因分析').add(line,'迭代测试bug数').add(bugtable, 'bug列表'))#标签页tab.render('''../reports/''' + str(report_name) + ".html")#以标签页为格式生成图表

再创建一个run.py文件来调用前两个文件

from script.operationJira import jiraOperation
from script.makeChart import chartsjira = jiraOperation.loginJira('url','username','password')
#登录jira   这个地方填写自己公司的jira地址和账号密码jira_jql = ["""labels = 1128迭代测试bug ORDER BY component DESC""","""labels = 1219迭代测试bug ORDER BY component DESC""","""labels = "2020/1/9" ORDER BY  component  DESC""",#"""labels = "2020/1/9" ORDER BY  component  DESC""",]
#每个迭代的jql放进去就好了jira_finail_result = []
for jql in  jira_jql:jira_result = jiraOperation.serchissues(jira,jql)#查询jira_result = list(jiraOperation.analytical(jira_result))jira_finail_result.append(jira_result)#对jira返回对象解析并整理成字典charts.make(jira_finail_result)
#生成图表

效果如图

pyecharts官方文档

pyecharts - A Python Echarts Plotting Library built with love.

JIra+Python+Pyechart 通过分析jira数据生成图表并展示,出具质量可视化的测试报告相关推荐

  1. python提取excel前十行生成图_Python读取Excel数据生成图表 v2.0

    Python读取Excel数据生成图表 v2.0 一.需求背景 自己一直在做一个周基金定投模拟,每周需要添加一行数据,并生成图表.以前一直是用Excel实现的.但数据行多后,图表大小调整总是不太方便, ...

  2. 使用python 处理表格生成图表_教你用Python自动读取数据生成图表,产生的效益很可观...

    厌烦了每次都要在Excel里拖动数据来生成图形吧,这篇文章里,教你用Python自动读取Excel数据生成图表,然后Python 使用XlsxWriter模块在Excel工作表中绘制带有数据表的柱形图 ...

  3. python读excel表格数据绘制图表_Python读取Excel数据生成图表 v2.0

    原博文 2020-06-15 15:09 − ## Python读取Excel数据生成图表 v2.0 ## 一.需求背景 自己一直在做一个周基金定投模拟,每周需要添加一行数据,并生成图表.以前一直是用 ...

  4. python批量生成图表_教你用Python自动读取数据生成图表,产生的效益很可观

    厌烦了每次都要在Excel里拖动数据来生成图形吧,这篇文章里,教你用Python自动读取Excel数据生成图表,然后Python 使用XlsxWriter模块在Excel工作表中绘制带有数据表的柱形图 ...

  5. 30分钟用python+pyechart写一个近期深圳的疫情地点展示

    @[TOC]30分钟用python+pyechart写一个近期深圳的疫情地点展示 背景 最近(今天20220227),深圳的–疫--情–又严重起来了.深圳卫健委天天都有在发病例XX,居住XX,只看地址 ...

  6. json 数据 生成 图表_CAPP工艺图表 / 知识重用 快速编制

    CAXA CAPP工艺图表致力于解决企业工艺编制阶段遇到的各种问题,提供图文混排.知识重用.工艺知识库.典型工艺.汇总统计等能力.帮助企业实现图文混排的快速工艺编制,实现关联信息同步自动修改.工艺资源 ...

  7. 使用 HighCharts 动态获取后台数据生成图表

    在最近的一个小项目中,因为需要统计一些数据,便想着把它做成一个图表的样式更直观的显示.因为考虑到需要在页面上灵活的展示,所以就放弃了使用 jfreechart,很早便听说过 HighCharts这个生 ...

  8. Day215.课程详细页面功能完善、Echarts统计分析模块[生成统计数据+生成图表]前后端整合 -谷粒学院

    谷粒学院 课程详细页面功能完善 一.修改课程详细接口 1.在service_order模块添加接口 用于判断订单中status值是否为1,为1则为已支付 @RestController @CrossO ...

  9. java实现将数据生成图表至excel导出(包括折线图,柱状图,饼状图)

    1. 目的 根据已有数据,手动(java后台)生成图表至excel并导出.用于后台查询到数据后直接创建图表,可以代替直接使用图表信息字符串. 2. 说明 使用jfree图表绘制类库绘制图表,并生成到本 ...

最新文章

  1. OFDM调制系统传输的复信号从何而来?
  2. 给array添加元素_前囧(06篇)Array 方法详解
  3. String.format()的使用
  4. Zing加快了JVM应用程序的预热
  5. 一个容易被忽视的css选择器
  6. 使用jmap命令手动导出映像文件?
  7. jquery分页插件的修改
  8. vue——缓存路由组件
  9. Excel中 对「对话气泡(吹き出し)」中的文字添加删除线 等操作
  10. java 字符串转long_如何在Java中将String转换为long?
  11. meteor---在合并打包多个文件ZIP下载的功能
  12. IPEmotion 2022 R1支持ARINC 429数据总线标准
  13. 4月第3周业务风控关注 |国家网信办启动小众即时通信工具专项整治
  14. source insight同步的时候崩溃_“我在国外,崩溃了一整年。”
  15. VS2019+WDK10编写xp平台的驱动
  16. Riak - 使用篇(1)
  17. Python UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xbb in position 0: invalid start byte
  18. TensorFlow实现:卷积神经网络识别手势动作(有代码与演示)
  19. 一文带你搞懂工厂设计模式
  20. 并行计算程序设计(CUDA C)

热门文章

  1. 百度智能云“寿光设施蔬菜智脑”项目斩获国际大奖
  2. TunesKit Video Repair for Mac(视频修复工具)
  3. Win11系统恢复经典的右键菜单方法
  4. 什么是IP地址,怎么查看修改IP地址?
  5. [读书笔记]第九章 当一只小猫扑向大狗 不论大狗多有理 人们总为小猫叫屈
  6. Failed to start LSB: Bring up/down networking
  7. H3C三层交换机配置DHCP
  8. 软件需求分析-原理、模型与误区
  9. 趁火打劫!“疫情做饵”的网络攻击来了
  10. 尚学堂Java第四章作业编码题+个人想法