Skip to content

Commit

Permalink
[FIXED JENKINS-8713] Display test skipped messages in test results
Browse files Browse the repository at this point in the history
  • Loading branch information
mc1arke committed Mar 13, 2013
1 parent c7ad5e9 commit 3b58cd2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
24 changes: 24 additions & 0 deletions core/src/main/java/hudson/tasks/junit/CaseResult.java
Expand Up @@ -56,6 +56,7 @@ public final class CaseResult extends TestResult implements Comparable<CaseResul
private final String testName;
private transient String safeName;
private final boolean skipped;
private final String skippedMessage;
private final String errorStackTrace;
private final String errorDetails;
private transient SuiteResult parent;
Expand Down Expand Up @@ -125,6 +126,7 @@ private static float parseTime(Element testCase) {
this.parent = parent;
duration = parseTime(testCase);
skipped = isMarkedAsSkipped(testCase);
skippedMessage = getSkippedMessage(testCase);
@SuppressWarnings("LeakingThisInConstructor")
Collection<CaseResult> _this = Collections.singleton(this);
stdout = possiblyTrimStdio(_this, keepLongStdio, testCase.elementText("system-out"));
Expand Down Expand Up @@ -165,6 +167,7 @@ static String possiblyTrimStdio(Collection<CaseResult> results, boolean keepLong
this.stderr = null;
this.duration = 0.0f;
this.skipped = false;
this.skippedMessage = null;
}

public ClassResult getParent() {
Expand Down Expand Up @@ -199,6 +202,17 @@ private static boolean isMarkedAsSkipped(Element testCase) {
return testCase.element("skipped") != null;
}

private static String getSkippedMessage(Element testCase) {
String message = null;
Element skippedElement = testCase.element("skipped");

if (skippedElement != null) {
message = skippedElement.attributeValue("message");
}

return message;
}

public String getDisplayName() {
return testName;
}
Expand Down Expand Up @@ -460,6 +474,16 @@ public boolean isSkipped() {
return skipped;
}

/**
* Provides the reason given for the test being being skipped.
* @return the message given for a skipped test if one has been provided, null otherwise.
* @since 1.507
*/
@Exported
public String getSkippedMessage() {
return skippedMessage;
}

public SuiteResult getSuiteResult() {
return parent;
}
Expand Down
Expand Up @@ -68,6 +68,11 @@ THE SOFTWARE.
</j:forEach>
</table>

<j:if test="${!empty(it.skippedMessage)}">
<h3>${%Skip Message}</h3>
<pre><j:out value="${it.annotate(it.skippedMessage)}"/></pre>
</j:if>

<j:if test="${!empty(it.errorDetails)}">
<h3>${%Error Message}</h3>
<pre><j:out value="${it.annotate(it.errorDetails)}"/></pre>
Expand Down

0 comments on commit 3b58cd2

Please sign in to comment.