мы используем с помощью mail-ext и каркас робота, чтобы попытаться отформатировать все детали тестовых наборов в jenkins, и отправить отчет.
вот отличный шаблон электронной почты, который мы использовали сейчас, его скачали сgithub, https://github.com/JMcn/jenkins-email-ext-templates/blob/master/robot.groovy.
, но этот шаблон сообщил о следующем исключении, как показано ниже, я не получил подобную ошибку при поиске в Google, все, что мы пропустили для этого шаблона, спасибо за любой намек на эту ошибку.
<%
import java.text.DateFormat
import java.text.SimpleDateFormat
%>
........
<!-- System Test Result -->
<%
def robotResults = false
def actions = build.actions // List<hudson.model.Action>
def robotTestResultAction = it.getAction("hudson.plugins.robot.RobotBuildAction")
actions.each() { action ->
if( robotTestResultAction != null ) {
//if( action && (action.class.simpleName.equals("RobotBuildAction") ) ) {
robotResults = true
%>
<TABLE width="100%">
<TR><TD class="bg1" colspan="4"><B>test results</B></TD></TR>
<TR style="border:1px solid #000;height:25px">
<TD>total</TD>
<TD>passed</TD>
<TD>failure</TD>
<TD>passrate</TD></TR>
<TR style="border:1px solid #000;height:25px">
<TD>${robotTestResultAction.getTotalCount()}</TD>
<TD style="color:green"><%=robotTestResultAction.getTotalCount() - robotTestResultAction.getFailCount()%></TD>
<TD style="color:red"><a style="color:red" href="${rooturl}${build.url}/${robotTestResultAction.urlName}">${robotTestResultAction.getFailCount()}</a></TD>
<TD>${robotTestResultAction.overallPassPercentage}%</TD></TR>
</TABLE>
<TABLE cellspacing="0" cellpadding="4" border="1" align="center">
<thead>
<tr bgcolor="#F3F3F3">
<td><b>test case name </b></td>
<td><b>state</b></td>
<td><b>execute duration</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="3"><b><%= suiteName %></b></td></tr>
<% DateFormat format = new SimpleDateFormat("yyyyMMdd HH:mm:ss.SS")
def execDateTcPairs = []
suite.caseResults.each() { tc ->
Date execDate = format.parse(tc.starttime)
execDateTcPairs << [execDate, tc]
}
// primary sort execDate, secondary displayName
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><%= tc.displayName %></td>
<td style="color: <%= tc.isPassed() ? "#66CC00" : "#FF3333" %>"><%= tc.isPassed() ? "PASS" : "FAIL" %></td>
<td><%= execDate %></td>
</tr>
<% } // tests
} // suites %>
</tbody>
</TABLE>
<%
} // robot results
}
if (!robotResults) {
%>
<TABLE width="100%">
<TR><TD class="bg1" colspan="2"><B>接口测试结果</B></TD></TR>
<TR><TD colspan="2">robotTestResultAction is null</TD></TR>
</TABLE>
<%
}
%>
<BR/>
Возникла исключительная ситуация при отображении шаблона: нет такого свойства: результат для класса: hudson.model.CauseAction groovy.lang.MissingPropertyException: Нет такого свойства: результат для класса: hudson.model.CauseAction в org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap (ScriptBytecodeAdapter.java:53) в org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty (GetEffectivePojoPropertySite.java:66) в org.codehausiteall.jt.Call.Ag.Cat.GoC296) в
после настройки сценария с использованием Krzysztof Błażełek 'Предполагается, что мы получили следующую ошибку:
<!-- System Test Result -->
<%
def robotResults = false
def actions = build.actions // List<hudson.model.Action>
//def robotTestResultAction = it.getAction("hudson.plugins.robot.RobotBuildAction")
actions.each() { action ->
//if( robotTestResultAction != null ) {
if( action && (action.class.simpleName.equals("RobotBuildAction") ) ) {
robotResults = true
Возникла исключительная ситуация во время рендеринга шаблона: Невозможно получить свойство 'simpleName' для нулевого объекта java.lang.NullPointerException: Невозможно получить свойство 'simpleName' для нулевого объекта в org.codehaus.NullCallSite.java!Способ) ....