Skip to content
Permalink
Browse files

JENKINS-22406: implemented tag storing and showing in test case page …

…and in failed cases summary
  • Loading branch information...
jipro committed May 27, 2014
1 parent 874f1cc commit 806648a78ac7aa0cde7ba3a94b6bfc7067c4b026
@@ -241,6 +241,9 @@ private RobotCaseResult processTest(XMLStreamReader reader, RobotSuiteResult res
//parse attributes
caseResult.setName(reader.getAttributeValue(null, "name"));
setCriticalityIfAvailable(reader, caseResult);
//parse test tags
ignoreUntilStarts(reader, "tags");
caseResult.addTags(processTags(reader));
//parse test details from nested status
ignoreUntilStarts(reader, "status");
caseResult.setPassed("PASS".equals(reader.getAttributeValue(null, "status")));
@@ -265,6 +268,26 @@ private RobotCaseResult processTest(XMLStreamReader reader, RobotSuiteResult res
return caseResult;
}

private List<String> processTags(XMLStreamReader reader) throws XMLStreamException {
List<String> taglist = new ArrayList<String>();
while(reader.hasNext()){
reader.next();
if(reader.isStartElement() && "tag".equals(reader.getLocalName())){
while(reader.hasNext()){
reader.next();
if(reader.getEventType() == XMLStreamReader.CHARACTERS){
taglist.add(reader.getText());
} else if(reader.isEndElement() && "tag".equals(reader.getLocalName())){
break;
}
}
} else if(reader.isEndElement() && "tags".equals(reader.getLocalName())){
break;
}
}
return taglist;
}

private static void setCriticalityIfAvailable(XMLStreamReader reader, RobotCaseResult caseResult) {
String criticality = reader.getAttributeValue(null, "critical");
if (criticality != null) {
@@ -24,7 +24,9 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;
import org.kohsuke.stapler.StaplerRequest;
@@ -42,6 +44,7 @@
private String name;
private String starttime;
private String endtime;
private List<String> tags;

private RobotSuiteResult parent;
private int failedSince;
@@ -149,6 +152,18 @@ public boolean isCritical() {
return critical;
}

public List<String> getTags(){
if(tags == null)
return new ArrayList<String>();
return tags;
}

public void addTags(List<String> taglist){
if(tags == null)
tags = new ArrayList<String>();
tags.addAll(taglist);
}

/**
* Gives the buildnumber of the build that this case first failed in
* @return number of build
@@ -34,6 +34,7 @@ limitations under the License.
Test execution took ${it.humanReadableDuration} (${it.getDurationDiff(prevcase)})
</div>
<h2 style="color:${headingColor};">${status}</h2>
<h4>| Tags: |<j:forEach var="tag" items="${it.tags}"><j:whitespace> ${tag} |</j:whitespace></j:forEach></h4>
<j:if test="${!it.isPassed()}">
<h3>Error message:</h3>
<p>${it.errorMsg}</p>
@@ -16,6 +16,7 @@ limitations under the License.
<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">
<st:contentType value="text/plain"/>
<h3>| Tags: |<j:forEach var="tag" items="${it.tags}"><j:whitespace> ${tag} |</j:whitespace></j:forEach></h3>
<h3>Error message:</h3>
<pre><st:out value="${it.errorMsg}"/></pre>
</j:jelly>
@@ -21,6 +21,7 @@
import java.util.List;

import junit.framework.TestCase;
import org.apache.commons.lang.StringUtils;


public class RobotResultTest extends TestCase {
@@ -150,6 +151,12 @@ public void testShouldReturnCaseById(){
assertEquals("Hello3rd", caseResult.getName());
}

public void testShouldReturnCaseTags(){
RobotCaseResult caseResult = (RobotCaseResult)result.findObjectById("Othercases & Testcases/Othercases/3rd level cases/Hello3rd");
String tags = StringUtils.join(caseResult.getTags(), ",");
assertEquals("tag1,tag2", tags);
}

public void testShouldParseSplittedOutput() throws Exception {
RobotParser.RobotParserCallable remoteOperation = new RobotParser.RobotParserCallable("testfile.xml");
result = remoteOperation.invoke(new File(new RobotSuiteResultTest().getClass().getResource("testfile.xml").toURI()).getParentFile(), null);
@@ -35,7 +35,10 @@
<status status="PASS" endtime="20100629 11:08:54.451" starttime="20100629 11:08:54.451">
</status>
</kw>
<tags></tags>
<tags>
<tag>tag1</tag>
<tag>tag2</tag>
</tags>
<status status="PASS" endtime="20100629 11:08:54.451" starttime="20100629 11:08:54.450">
</status>
</test>

0 comments on commit 806648a

Please sign in to comment.
You can’t perform that action at this time.