Skip to content

Commit 24bf419

Browse files
authored
Create the SkippedSection helly, update the Age based on the current result to be skipped or passed (#87)
1 parent dbd6d98 commit 24bf419

File tree

4 files changed

+83
-3
lines changed

4 files changed

+83
-3
lines changed

src/main/java/hudson/plugins/robot/model/RobotCaseResult.java

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class RobotCaseResult extends RobotTestObject{
5454

5555
private RobotSuiteResult parent;
5656
private int failedSince;
57+
private int skippedSince;
5758

5859
/**
5960
* Difference between string timevalues in format yyyyMMdd HH:mm:ss.SS (Java DateFormat).
@@ -232,6 +233,24 @@ else if (getOwner() != null) {
232233
return failedSince;
233234
}
234235

236+
public int getSkippedSince() {
237+
if (skippedSince == 0 && isSkipped()) {
238+
RobotCaseResult previous = getPreviousResult();
239+
if(previous != null && previous.isSkipped())
240+
this.skippedSince = previous.getSkippedSince();
241+
else if (getOwner() != null) {
242+
this.skippedSince = getOwner().getNumber();
243+
} else {
244+
LOGGER.warn("trouble calculating getSkippedSince. We've got prev, but no owner.");
245+
}
246+
}
247+
return skippedSince;
248+
}
249+
250+
public void setSkippedSince(int skippedSince) {
251+
this.skippedSince = skippedSince;
252+
}
253+
235254
public void setFailedSince(int failedSince) {
236255
this.failedSince = failedSince;
237256
}
@@ -259,14 +278,24 @@ public Run<?,?> getFailedSinceRun() {
259278
}
260279

261280
/**
262-
* Get the number of builds this test case has failed for
281+
* Gives the run that this case first skipped in
282+
* @return run object
283+
*/
284+
public Run<?,?> getSkippedSinceRun() {
285+
return getOwner().getParent().getBuildByNumber(getSkippedSince());
286+
}
287+
288+
/**
289+
* Get the number of builds this test case has failed/skipped for
263290
* @return number of builds
264291
*/
265292
public int getAge(){
266293
if(isPassed()) return 0;
267294
Run<?,?> owner = getOwner();
268-
if(owner != null)
269-
return getOwner().getNumber() - getFailedSince() + 1;
295+
if(owner != null) {
296+
int previousStatusBuild = isSkipped() ? getSkippedSince() : getFailedSince();
297+
return getOwner().getNumber() - previousStatusBuild + 1;
298+
}
270299
else return 0;
271300
}
272301

src/main/resources/hudson/plugins/robot/model/RobotResult/index.jelly

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ limitations under the License.
6868
<div style="margin-bottom=20px;">
6969
<u:failedCases />
7070
</div>
71+
<div style="margin-bottom=20px;">
72+
<u:skippedCases />
73+
</div>
7174

7275
<h2>Test Suites</h2>
7376
<table class="pane sortable">

src/main/resources/hudson/plugins/robot/model/RobotSuiteResult/index.jelly

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ limitations under the License.
100100
<div style="margin-bottom=20px;">
101101
<u:failedCases />
102102
</div>
103+
<div style="margin-bottom=20px;">
104+
<u:skippedCases />
105+
</div>
103106
<h2>Nested Test Suites</h2>
104107
<table class="pane sortable">
105108
<tr>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<?jelly escape-by-default='true'?>
3+
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:u="/util">
4+
<script src="${rootURL}/plugin/robot/robot.js"/>
5+
<j:if test="${!it.allSkippedCases.isEmpty()}">
6+
<style>
7+
td.pane {
8+
vertical-align: top;
9+
}
10+
</style>
11+
<h2>Skipped Test Cases</h2>
12+
<table class="pane sortable">
13+
<tr>
14+
<td class="pane-header" title="Test case name. Click to sort.">Name</td>
15+
<td class="pane-header" title="Duration. Click to sort.">Duration</td>
16+
<td class="pane-header" style="text-align:center;" title="Number of skipped builds. Click to sort.">Age</td>
17+
</tr>
18+
<j:forEach var="case" items="${it.allSkippedCases}">
19+
<j:set var="fullName" value="${case.getRelativePackageName(it)}" />
20+
<j:set var="relativeId" value="${case.getRelativeId(it)}" />
21+
<j:set var="escapedName" value="${h.escape(fullName)}" />
22+
<tr>
23+
<td class="pane">
24+
<a id="${escapedName}-showlink" href="#" class="robot-expand" data-escaped-name="${escapedName}" data-relative-id="${relativeId}/summary"></a>
25+
<a id="${escapedName}-hidelink" href="#" style="display:none" class="robot-collapse" data-escaped-name="${escapedName}"></a>
26+
<st:nbsp/>
27+
<a href="${relativeId}"><small>${case.getRelativeParent(it)}</small>${case.name}</a>
28+
<div id="${escapedName}" class="hidden" style="display:none">
29+
${%Loading...}
30+
</div>
31+
</td>
32+
<td class="pane">${case.humanReadableDuration}</td>
33+
<td class="pane" style="text-align:center;">
34+
<j:if test="${case.skippedSinceRun != null}">
35+
<a href="${rootURL}/${case.skippedSinceRun.url}">${case.age}</a>
36+
</j:if>
37+
<j:if test="${case.skippedSinceRun == null}">
38+
${case.age}
39+
</j:if>
40+
</td>
41+
</tr>
42+
</j:forEach>
43+
</table>
44+
</j:if>
45+
</j:jelly>

0 commit comments

Comments
 (0)