Jenkins(二)之自定义Robot Framework结果报告
目标:
实现RobotFramework的脚本定时自动执行,执行完后自动将结果发送到指定邮箱
前提
1、 配置好Robot Framework的环境,脚本可以正常运行,如果不会请看我之前写的博客Robot Framework 环境搭建
2、 部署好Jenkins的环境,Jenkins的安装不是本文的重点,不懂的请问度娘(其实很简单,装Tomcat,把Jenkins.war包扔到Tomcat的webapp目录里)
3、 在Jenkins里安装好以下插件:Email Extension Plugin、Zentimestamp plugin、Robot Framework plugin
配置
1、进入【系统管理】-【系统设置】进行如下配置:
》设置${BUILD_TIMESTAMP}格式
》配置 Extended E-mail Notification默认设置
2、创建一个任务
3、任务的配置
》设置保留的构建的数量
》设置每天凌晨1点的时候自动执行
》增加构建步骤,类型为:Execute shell
》设置运行RobotFramework脚本的命令,这里用-d 来定义RobotFramework的结果输出目录,格式如:
robot -d /结果输出/${BUILD_TIMESTAMP} /脚本目录/
- 1
这里用${BUILD_TIMESTAMP}环境变量是让每次构建的结构都放在以日期格式命名的文件夹里
》增加构建后操作步骤Publish Robot Framework test results,配置如下:
》再增加一个构建后操作步骤Editable Email Notification,配置可以默认,也可以根据你的需要来配置,以下是我的配置:
4、自定义RobotFramework结构汇总的邮件模板格式,效果如:
大家是否记得前面 Extended E-mail Notification默认设置里Default Content的值是填写 ${SCRIPT, template=”robot_results.groovy”}
这里就告诉大家怎么去设置这个模板
在$Jenkins_Home/email-templates目录(如果没有email-templates请自行创建)下创建一个robot_results.groovy文件,内容如下:
<% import java.text.DateFormat import java.text.SimpleDateFormat %> <!-- Robot Framework Results -->
<% def robotResults = false def actions = build.actions // List<hudson.model.Action> actions.each() { action -> if( action.class.simpleName.equals("RobotBuildAction") ) { // hudson.plugins.robot.RobotBuildAction robotResults = true %><div style="width:100%;float:left"> <table cellspacing="0" cellpadding="4" border="1" align="left"> <thead><tr bgcolor="#F3F3F3"><td style="text-align:center" colspan="4"><b>自动化测试汇总报告</b></td> </tr><tr><td bgcolor="#F3F3F3" style="width:80px"><b>详细报告:</b></td><td colspan="4"><a href="${rooturl}${build.url}robot/report/report.html">点击查看报告详情</a></td></tr> <tr bgcolor="#F3F3F3"><td><b>用例总数</b></td><td><b>通过</b></td><td style="width:60px"><b>不通过</b></td><td style="width:100px"><b>通过率</b></td></tr><tr><td><%= action.result.overallTotal %></td><td><b><span style="color:#66CC00"><%= action.result.overallPassed %></span></b></td><td><b><span style="color:#FF3333"><%= action.result.overallFailed %></span></b></td><td><%= action.overallPassPercentage %>%</td></tr><tr bgcolor="#F3F3F3"> <td colspan="2"><b>Test Name</b></td> <td><b>Status</b></td> <td><b>Elapsed Time</b></td> </tr> </thead> <tbody> <% def suites = action.result.allSuites suites.each() { suite -> def currSuite = suite def suiteName = currSuite.displayName // ignore top 2 elements in the structure as they are placeholders while (currSuite.parent != null && currSuite.parent.parent != null) { currSuite = currSuite.parent suiteName = currSuite.displayName + "." + suiteName } %> <tr><td colspan="4"><b><%= suiteName %></b></td></tr> <% DateFormat format = new SimpleDateFormat("yyyyMMdd HH:mm:ss")def execDateTcPairs = []suite.caseResults.each() { tc -> Date execDate = format.parse(tc.starttime)execDateTcPairs << [execDate, tc]}// primary sort execDate, secondary displayNameexecDateTcPairs = execDateTcPairs.sort{ a,b -> a[1].displayName <=> b[1].displayName }execDateTcPairs = execDateTcPairs.sort{ a,b -> a[0] <=> b[0] }execDateTcPairs.each() {def execDate = it[0]def tc = it[1] %><tr> <td colspan="2"><%= tc.displayName %></td> <td><b><span style="color:<%= tc.isPassed() ? "#66CC00" : "#FF3333" %>"><%= tc.isPassed() ? "PASS" : "FAIL" %></span></b></td> <td><%= tc.getDuration().intdiv(60000)+"分"+(tc.getDuration()-tc.getDuration().intdiv(60000)*60000).intdiv(1000)+"秒" %></td> </tr> <% if(tc.errorMsg != null) {%><tr><td ><b><span style="font-size:10px;color:#FF3333">错误描述:</span></b></td><td colspan="3"><span style="font-size:10px"><%= tc.errorMsg%></span></td></tr><%}%>
<% } // tests } // suites %> </tbody></table><p style="color:#AE0000;clear:both">*这个是通过Jenkins自动构建得出的报告,仅供参考。</p></div><% } // robot results } if (!robotResults) { %> <p>No Robot Framework test results found.</p>
<% } %>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
其中Jenkins_Home的路径不知道在哪里的话,你可以去看一下系统设置页面,上面有写有:
完!
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/markdown_views-ea0013b516.css"></div>
Jenkins(二)之自定义Robot Framework结果报告相关推荐
- Robot Framework自定义测试库
用Python自定义Robot Framework测试库 http://automationqa.com/forum.php?mod=viewthread&tid=1792 用Java自定义r ...
- 【Jenkins+RF】从零搭建Jenkins+Robot Framework持续集成环境
转自:https://www.jianshu.com/p/ef8d3109ac5f 感恩 安装Jenkins 系统环境:CentOS Linux release 7.3.1611 x86_64 ...
- 从零搭建Robot Framework+Jenkins持续集成环境
安装Jenkins 系统环境:CentOS Linux release 7.3.1611 x86_64 GNU/Linux 安装JDK Jenkins是基于Java开发的持续集成系统(CI),所以运行 ...
- Robot Framework用户指南
Robot Framework用户指南 版本2.8.6 版权所有©诺基亚解决方案和网络2008-2014 根据知识共享署名3.0 Unported许可授权 目录 1开始 1.1简介 1.2版权和许可 ...
- Python3+Robot Framework+RIDE安装使用教程
Python3+Robot Framework+RIDE安装使用教程 一.说明 Python3----网上很多文章都是用Python2,Robot Framework的部分文档没更新也直接写着不支持P ...
- [原]Jenkins(二十) jenkins再出发之Error: Opening Robot Framework log failed
错误缘由:使用plugin [public robot framework test results] 生成的HTML文件都无法正常打开. 解决方案: Connect on your jenkins ...
- robot framework集成Jenkins环境
一.Jenkins工具介绍: 监视重复工作的执行,本质上提供了一个易于使用的持续集成系统,使得开发人员更容易地将改变集成到工程中,使得用户更容易获得一个新的build.自动化,持续的构建提高了软件开发 ...
- 【转】解决从jenkins打开robot framework报告会提示‘Opening Robot Framework log failed ’的问题...
最新的jenkins打开jenkins robot framework报告会提示如下 Verify that you have JavaScript enabled in your browser. ...
- Robot Framework自动化测试框架核心指南-如何使用Java编写自定义的RobotFramework Lib
如何使用Java编写自定义的RobotFramework Lib 本文包括2个章节 1. Robot Frdamwork中如何调用java Lib库 2.使用 java编写自定义的Lib 本文作者为: ...
- Jenkins Robot framework 持续集成环境搭建
为什么我们要引入RF?其实最初我们引入RF是为了能够快速的开展自动化验收测试,为敏捷保驾护航.这其中有个重要的工具Jenkins,同时也是应群里朋友们的要求,这次就来介绍一下RF如何快速便捷的结合Je ...
最新文章
- Python Qt GUI设计:多线程中信号与槽的使用(基础篇—9)
- cocos2d-x一些核心概念介绍
- 如何消费WCF Data Services定义的服务操作
- HTTP 请求头中的 Remote_Addr,X-Forwarded-For,X-Real-IP
- yolt 卫星图像进行快速目标识别的新方法
- Wcf 双工通信的应用
- Call调用webservice接口,使用命名空间和不使用命名空间的区别
- 使用webpack打包vue工程
- monkey 运行时间怎么计算_基于STM32F103C8T6工控板利用定时器计算某段代码的运行时间...
- android笔试添加自定义服务,Android之Listview(item为单选题)自定义adapter,像考试时前面的10几道单选题的实现...
- oracle中表空间详解
- mac下php的坑,MAC下安装laravel时遇到的坑
- requestmapping注解访问404_开发人员都必须知道的Spring注解概览
- 95-190-742-源码-WindowFunction-AllWindowFunction
- ubuntu 16.0安装mysql8_ubuntu16.0.4 安装 mysql8.0.18的
- Java开发笔记(一百三十七)JavaFX的标签
- Ruby类的创建与使用
- matlab帧差法图像识别
- Authentication—身份验证流程
- JS 进阶 (六) 浏览器事件模型DOM操作