<%
import java.text.DateFormat
import java.text.SimpleDateFormat
%>
<!-- Robot Framework Results -->
<!DOCTYPE html>
<html>
<style type="text/css">
table {width:1200px;table-layout:fixed;}
td {width:180px;}
td.title {
background-color:#8F8F8F;
text-align: center;
}
td.suite{background-color:#EEE8AA;}
td.case{background-color:#dff0d8;}
td.head{background-color:#8F8F8F;}
td.error {background-color:#FF6666;}
table thead tboday tr td {cellspacing:0px;border:1px;}
h2.span{color:white;}
span.pass{color:#66CC00;}
span.fail{color:#FF3333;}
</style>
<body>
<table width="95%" cellpadding="0" cellspacing="0" style="font-size:15pt; font-family:Tahoma,Arial,Helvetica,sans-serif">
<tr>
<td>
<h4><font color="##0B610B">(本邮件由Jenkins自动下发,请勿回复!)</font></h4>
</td>
</tr>
<tr>
<td>
<b><font color="#0B610B">构建信息:</font></b>
<hr size="2" width="100%" align="center" />
</td>
</tr>
<tr>
<td>
<ul>
<li>项目名称:${project.name}</li>
<li>构建项目:XXXX构建测试</li>
<li>构建编号:${build.number}</li>
<li>构建目的:XXXX每日构建环境,jenkins平台自动执行测试用例</li>
<li>XX版本:V1.08.0.01.92</li>
<li>XX版本:NeSoft V01.09.00 2022-05-19 02:11:25 </li>
<li>FPGA版本:bit_nq_202206060548_V1p9_1</li>
<li>XXX版本:V1.9 </li>
</ul>
</td>
</tr>
<tr>
<td>
<b><font color="#0B610B">测试报告:</font></b>
<hr size="2" width="100%" align="center" />
</td>
</tr>
</table>
<%
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>
<table cellpadding="4" align="left">
<thead>
<tr>
<td class="title" colspan="4"><h2><span>${project.name}</span><span> 自动化测试报告</span></h2></td>
</tr>
<tr>
<td class="case"><b>详细报告</b></td>
<td colspan="3" class="case"><a href="${rooturl}${build.url}robot/report/report.html">点击查看报告详情</a> (用户名:user 密码:123456)</td>
<!--<td colspan="3" class="case"><a href="file://192.168.40.167/log/report.html">file://192.168.40.167/log/report.html</a></td>-->
</tr>
<tr>
<td class="case"><b>构建URL</b></td>
<td colspan="3" class="case"><a href="${rooturl}${build.url}">${rooturl}${build.url}</a></td>
</tr>
<tr>
<td class="head"><b>用例总数</b></td>
<td class="head"><b>通过</b></td>
<td class="head"><b>不通过</b></td>
<td class="head"><b>通过率</b></td>
</tr>
<tr>
<td class="case"><%= action.result.overallTotal %></td>
<td class="case"><b><span class="pass"><%= action.result.overallPassed %></span></b></td>
<td class="case"><b><span class="fail"><%= action.result.overallFailed %></span></b></td>
<td class="case"><%= action.overallPassPercentage %>%</td>
</tr>
<tr>
<td colspan="2" class="head"><b>Test Name</b></td>
<td class="head"><b>Status</b></td>
<td class="head"><b>Elapsed Time</b></td>
</tr>
</thead>
<tboday>
<%
def suites = action.result.allSuites
suites.each() { suite ->
def currSuite = suite
def suiteName = currSuite.displayName
//忽略最上层结构两个占位的元素
while (currSuite.parent != null && currSuite.parent.parent != null) {
currSuite = currSuite.parent
suiteName = currSuite.displayName + "." + suiteName
}
%>
<tr>
<td colspan="4" class="suite"><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]
}
//按执行日期、显示名称进行排序
execDateTcPairs = 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" class="case"><%= tc.displayName %></td>
<td class="case"><b><span style="color:<%= tc.isPassed() ? "#66CC00" : "#FF3333" %>"><%= tc.isPassed() ? "PASS" : "FAIL" %></span></b></td>
<td class="case"><%= tc.getDuration().intdiv(60000)+"分"+(tc.getDuration()-tc.getDuration().intdiv(60000)*60000).intdiv(1000)+"秒" %></td>
</tr>
<%
} // tests
} // suites
%>
</tboday>
</table>
</div>
<%
} // robot results
}
if (!robotResults){
%>
<p>No Robot Framework test results found.</p>
<%}%>
</body>
</html>
robot_results.groovy
最新推荐文章于 2024-09-29 12:39:27 发布