软件测试报告
前言
软件测试报告在软件开发过程中起着至关重要的作用:①记录测试过程和结果;②评估软件质量;③指导缺陷修复;④为项目总结提供依据。
编写并发送测试报告是测试人员的日常工作之一,编写一份测试报告的时间在15min左右,如果需要发送测试日报的话,那么一周写报告的时间就可能占用我们1h之久。而编写测试报告往往是重复的、枯燥的、有模板的。由此,我们可以考虑自动生成测试报告并发送。
一、测试报告包含哪些内容?
1、测试的需求(需求的创建者、开发者、测试人员);
2、本期测试的遗留问题(对应的开发者、测试人员);
3、本期测试的需求和bug数量的对应关系;
4、本期测试的总bug趋势;
5、产品验收的地址及账号密码等;
6、本期发布的注意事项。
通用的测试报告一般包含以上内容,每日的测试日报和每期发版的测试报告会有一些差别,但基本都在上面的范围中了。
二、测试报告自动化
1.可行性
由于测试报告包含的内容是固定的,且发布的需求、遗留的bug等都是有原始数据的。比如有些公司会使用禅道、jira等,或者是使用公司自己开发的平台管理这些数据。但不管是使用什么平台,终归是存在原始数据的,只要我们把这些数据拿过来,稍加整合,就能成为我们的测试报告内容。
2.报告设计
根据测试报告需要包含的内容,我做了如下设计:
2.1可编辑部分(填写验收地址和注意事项等):
2.2不可编辑部分(自动生成)
2.3发送测试报告
填写完报告的可编辑部分及报告数据生成完毕后就可以发送报告了,点击发送验收邮件如下:
3.前端页面实现
大部分的测试同学前端编码能力一般或较低,为了实现一个报告模板去学习前端时间成本太高。所以我们可以选择市面上的比较主流的低代码框架。这里也不去介绍和比较不同低代码框架的优劣。我使用的是百度开源的amis框架。大家可以去官网详细学习,amis官方文档,也可以直接使用我调试好的代码
{
"type": "page",
"body": [
{
"type": "grid",
"columns": [],
"id": "u:18117b3b20df"
},
{
"type": "crud",
"api": {
"url": "${ip}/api/test/stories/${projectId}",
"method": "post",
"messages": {},
"requestAdaptor": "",
"adaptor": "",
"dataType": "json",
"data": {
"projectId": "${projectId}"
}
},
"syncLocation": false,
"autoGenerateFilter": true,
"headerToolbar": [
{
"type": "bulk-actions",
"tpl": "内容",
"id": "u:22745defa189",
"align": "left"
}
],
"perPageAvailable": [],
"messages": {},
"mode": "table",
"initFetch": true,
"hideQuickSaveBtn": false,
"autoJumpToTopOnPagerChange": true,
"footerToolbar": [],
"alwaysShowPagination": false,
"bulkActions": [
{
"actionType": "ajax",
"label": "选择需求,生成报告",
"id": "u:ca08d1207547",
"level": "primary",
"visible": true,
"onEvent": {
"click": {
"weight": 0,
"actions": [
{
"ignoreError": false,
"actionType": "drawer",
"drawer": {
"type": "drawer",
"body": [
{
"type": "container",
"id": "u:7703c1204cb4",
"body": [
{
"type": "form",
"id": "u:46f5a4edc95b",
"title": "测试报告预览",
"mode": "horizontal",
"dsType": "api",
"feat": "Edit",
"body": [
{
"type": "tpl",
"tpl": "大家好:XXX项目以下需求已测试完毕,请产品验收。本期产品:张三,本期测试:李四、王五",
"inline": true,
"wrapperComponent": "",
"id": "u:d65e0e826df1"
},
{
"name": "urlAndAccount",
"label": "一、验收地址和账号",
"type": "textarea",
"id": "u:da4fcfcd99ff",
"minRows": 3,
"maxRows": 20,
"mode": "normal",
"required": true,
"placeholder": "请填写产品验收的网页地址及登录账密"
},
{
"name": "note",
"label": "二、本期项目的注意事项",
"type": "textarea",
"id": "u:280da501989f",
"minRows": 3,
"maxRows": 20,
"mode": "normal",
"required": true,
"placeholder": "请填写本期项目需求的注意事项"
}
],
"api": {
"url": "${ip}/api/test/saveEmailContent",
"method": "post",
"data": {
"urlAndAccount": "${urlAndAccount}",
"note": "${note}",
"projectId": "${projectId}"
}
},
"actions": [
{
"type": "button",
"label": "保存邮件数据",
"onEvent": {
"click": {
"actions": [
{
"actionType": "submit",
"componentId": "u:46f5a4edc95b"
},
{
"componentId": "u:46f5a4edc95b",
"ignoreError": false,
"actionType": "reload",
"dataMergeMode": "override",
"data": {
"urlAndAccount": "${urlAndAccount}",
"projectId": "${projectId}",
"note": "${note}"
}
}
]
}
},
"level": "primary",
"id": "u:d8bad8f0a880"
}
],
"resetAfterSubmit": true,
"initApi": {
"url": "${ip}/api/test/saveEmailContent",
"method": "post",
"requestAdaptor": "",
"adaptor": "",
"messages": {},
"data": {
"urlAndAccount": "${urlAndAccount}",
"note": "${note}",
"projectId": "${projectId}"
}
}
},
{
"type": "panel",
"title": "测试报告预览",
"body": [
{
"type": "divider",
"id": "u:b13c1f26e394"
},
{
"type": "grid",
"className": "m-t-lg",
"columns": [],
"id": "u:3e14a178ad37"
},
{
"type": "service",
"api": {
"url": "${ip}/api/test/result",
"method": "post",
"requestAdaptor": "",
"adaptor": "",
"messages": {},
"data": {
"ids": "${ids}",
"projectId": "${projectId}"
}
},
"body": [
{
"type": "table",
"title": "三、本期项目测试完成的需求清单:",
"columns": [
{
"name": "storyid",
"label": "编号",
"id": "u:7585b4a7aa34"
},
{
"name": "productname",
"label": "所属产品",
"id": "u:f3ed8a19b35c"
},
{
"name": "moudlename",
"label": "所属模块",
"id": "u:23591b14ba40"
},
{
"name": "projectname",
"label": "所属计划",
"id": "u:30f5a46d2582"
},
{
"name": "storytitle",
"label": "需求名称",
"id": "u:33e4ca8f0699"
},
{
"name": "storyowner",
"label": "由谁创建",
"id": "u:38168332605d"
},
{
"name": "tester",
"label": "测试人员",
"id": "u:843577e3b98f"
},
{
"name": "bugs",
"label": "bug遗留情况",
"id": "u:37f89e6d6022"
},
{
"id": "u:54f8bd763b25",
"name": "conclusion",
"classNameExpr": "<%= data.conclusion == '测试不通过'? 'text-danger' : 'text-success'%>",
"label": "测试结论"
}
],
"id": "u:dbe5077d2ef9"
}
],
"id": "u:279751777607",
"dsType": "api",
"visibleOn": "",
"onEvent": {
"init": {
"weight": 0,
"actions": [
{
"componentId": "u:279751777607",
"ignoreError": false,
"actionType": "setValue",
"args": {
"value": {
"outputVar": "responseResultDi"
}
}
}
]
}
}
},
{
"type": "service",
"id": "u:caa057be5f28",
"api": {
"url": "${ip}/api/test/bugs",
"method": "post",
"requestAdaptor": "",
"adaptor": "",
"messages": {},
"data": {
"ids": "${ids}",
"projectId": "${projectId}"
}
},
"body": [
{
"type": "chart",
"name": "chart1",
"initFetch": true,
"api": {
"method": "post",
"url": "${ip}/api/test/getStoryBug",
"requestAdaptor": "",
"adaptor": "",
"messages": {},
"data": {
"ids": "${ids}",
"projectId": "${projectId}"
}
},
"id": "u:56a81e30d648",
"dataFilter": ""
},
{
"type": "tpl",
"tpl": "说明:此柱状图为本期所有需要上线需求的BUG情况,橙色为P1/P2级别BUG,蓝色为P3/P4级别BUG,横坐标为需求ID,纵坐标为BUG数量。柱状图越高代表软件质量越差,存在的风险也更高,反之,则软件质量较好,风险可控。",
"inline": true,
"wrapperComponent": "",
"id": "u:f38ce1c48bf4"
},
{
"type": "table",
"title": "四、本期需求遗留的bug:",
"columns": [
{
"name": "id",
"label": "ID",
"id": "u:0b2c265bc08a"
},
{
"name": "severity",
"label": "优先级",
"id": "u:013221bb4a0c"
},
{
"name": "isconfirmed",
"label": "确认",
"id": "u:094e68c777c3"
},
{
"name": "title",
"label": "Bug标题",
"id": "u:4e46eba1d0a6"
},
{
"name": "bugtype",
"label": "Bug类型",
"id": "u:41f211fbc750"
},
{
"name": "bugstatus",
"label": "状态",
"id": "u:2bccb3861b94"
},
{
"name": "creator",
"label": "创建者",
"id": "u:dd3c5d07b9fb"
},
{
"name": "creatime",
"label": "创建日期",
"id": "u:da1e6f0c0903"
},
{
"name": "pointto",
"label": "指派给",
"id": "u:4df301a54ae8"
}
],
"id": "u:3557289d4925"
}
],
"dsType": "api"
},
{
"type": "chart",
"name": "chart1",
"initFetch": true,
"api": {
"method": "post",
"url": "${ip}/api/test/histogram",
"requestAdaptor": "",
"adaptor": "",
"messages": {},
"data": {
"ids": "${ids}",
"projectId": "${projectId}"
}
},
"id": "u:3a4cb10c262e",
"dataFilter": ""
},
{
"type": "tpl",
"tpl": "说明:遗留BUG数量情况,理论上不能带P1、P2级BUG上线,P3+P4级别最好不要超过3个。",
"inline": true,
"wrapperComponent": "",
"id": "u:f188e51cc454"
},
{
"type": "chart",
"name": "chart1",
"initFetch": true,
"api": {
"method": "post",
"url": "${ip}/api/test/barchart",
"requestAdaptor": "",
"adaptor": "",
"messages": {},
"data": {
"ids": "${ids}",
"projectId": "${projectId}"
}
},
"id": "u:9bdb203c2c82",
"dataFilter": ""
},
{
"type": "tpl",
"tpl": "说明:若临近上线BUG仍存在上升趋势,代表潜藏的软件质量风险越高。",
"inline": true,
"wrapperComponent": "",
"id": "u:d9865de84fd5"
}
],
"id": "u:df113be3d564",
"affixFooter": false,
"visible": true,
"subFormMode": "inline",
"actions": [
{
"type": "button",
"label": "发送验收邮件",
"onEvent": {
"click": {
"actions": [
{
"ignoreError": false,
"actionType": "dialog",
"dialog": {
"type": "dialog",
"body": [
{
"id": "u:56d5c4f5605a",
"type": "form",
"title": "表单",
"mode": "horizontal",
"dsType": "api",
"feat": "Insert",
"body": [
{
"name": "emailTitle",
"label": "邮件标题",
"type": "input-text",
"id": "u:6849439b1841",
"required": true
},
{
"type": "select",
"label": "邮件主送",
"name": "importantSend",
"id": "u:aa782d903c25",
"minRows": 3,
"maxRows": 20,
"multiple": true,
"required": true,
"source": {
"url": "${ip}/api/test/user",
"method": "post"
},
"labelField": "userName",
"valueField": "userId",
"showInvalidMatch": false,
"checkAll": true,
"trimContents": true,
"defaultCheckAll": false,
"checkAllLabel": "全选",
"searchable": true,
"clearable": true,
"joinValues": true,
"delimiter": ","
},
{
"type": "select",
"label": "邮件抄送",
"name": "secondarySend",
"id": "u:834e581c9a88",
"minRows": 3,
"maxRows": 20,
"multiple": true,
"source": {
"url": "${ip}/api/test/user",
"method": "post"
},
"labelField": "userName",
"valueField": "userId",
"showInvalidMatch": false,
"checkAll": true,
"trimContents": true,
"defaultCheckAll": false,
"checkAllLabel": "全选",
"joinValues": true,
"delimiter": ",",
"searchable": true,
"clearable": true
}
],
"api": {
"url": "${ip}/api/test/sendEmail/${projectId}",
"method": "post",
"requestAdaptor": "",
"adaptor": "",
"messages": {},
"data": {
"ids": "${ids}",
"emailTitle": "${emailTitle}",
"importantSend": "${importantSend}",
"secondarySend": "${secondarySend}"
},
"dataType": "json"
},
"resetAfterSubmit": true,
"debug": false,
"actions": [
{
"type": "submit",
"label": "确定",
"primary": true
}
]
}
],
"showCloseButton": true,
"showErrorMsg": true,
"showLoading": true,
"className": "app-popover",
"id": "u:71a3da18fafb",
"title": "发送测试邮件",
"actions": [
{
"type": "button",
"actionType": "cancel",
"label": "取消",
"id": "u:899aec4ddee9"
},
{
"type": "button",
"actionType": "confirm",
"label": "确定",
"primary": true,
"id": "u:3a41e1df781f"
}
]
}
}
]
}
},
"id": "u:ee77acd38cfe",
"level": "warning"
},
{
"type": "button",
"label": "查看报告详情",
"onEvent": {
"click": {
"actions": [
{
"ignoreError": false,
"actionType": "url",
"args": {
"url": "/index.html#/tools/testReports",
"params": {
"projectId": "${projectId}",
"ids": "${ids}"
}
}
}
]
}
},
"id": "u:4a4e4a9f3893",
"level": "enhance"
}
]
}
],
"size": "xs",
"style": {
"position": "static",
"display": "block",
"flex": "1 1 auto",
"flexGrow": 1,
"flexBasis": "auto"
},
"wrapperBody": false,
"isFixedHeight": false,
"isFixedWidth": false
}
],
"className": "app-popover",
"actions": [],
"id": "u:41de4935cabb",
"resizable": true,
"width": 1200
}
}
]
}
}
}
],
"id": "u:a22734959e47",
"columns": [
{
"name": "id",
"label": "需求ID",
"id": "u:4cea9b1a3fe9",
"placeholder": "-"
},
{
"name": "story",
"label": "需求名称",
"id": "u:c3a2d22a4471",
"placeholder": "-"
},
{
"name": "owner",
"label": "产品",
"id": "u:4cea9b1a3fe9",
"placeholder": "-"
},
{
"name": "statusStr",
"label": "状态",
"id": "u:c3a2d22a4471",
"placeholder": "-"
},
{
"name": "stageStr",
"label": "阶段",
"id": "u:e3d2a12f438c",
"placeholder": "-"
}
],
"filter": {
"title": "请选择需要生成测试报告的项目",
"body": [
{
"type": "select",
"name": "projectId",
"label": "选择项目:",
"id": "u:95d26cd0080a",
"multiple": false,
"mode": "horizontal",
"source": {
"url": "${ip}/api/test/projects",
"method": "post"
},
"labelField": "projectName",
"valueField": "projectId",
"selectFirst": true,
"required": true
}
],
"id": "u:867cae04e7e6",
"actions": [
{
"type": "submit",
"label": "搜索",
"primary": true,
"id": "u:0a4a07427ff6"
}
],
"feat": "Insert"
}
}
],
"id": "u:2b466bca85b8",
"asideResizor": false,
"pullRefresh": {
"disabled": true
},
"title": "测试报告demo"
}
我编写的模版中使用到了自己开发的后端代码,大家可以根据自己的需要mock接口来体验前端功能。要使前端项目可运行起来,还需要安装node.js。
总结
本文介绍了测试报告模板化、自动化是可行的,大家可以尝试体验:
前端项目地址:https://gitee.com/juanmaoli/test-report-demo.git