Skip to content

Commit

Permalink
Merge pull request #58 from jenkinsci/JENKINS-69807
Browse files Browse the repository at this point in the history
  • Loading branch information
Tattoo committed Mar 14, 2023
2 parents 693e6a2 + 8b606f6 commit 90aafd7
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
Expand Up @@ -98,7 +98,14 @@ public boolean getHasReport() {
* @return package name
*/
public String getRelativePackageName(RobotTestObject thisObject) {
StringBuilder sb = new StringBuilder(getName());
/*
`name` attribute might be missing from suites, see more: https://issues.jenkins.io/browse/JENKINS-69807
*/
String name = getName();
if (name == null){
name = "";
}
StringBuilder sb = new StringBuilder(name);
String parentPackage = getRelativeParent(thisObject);
if (! "".equals(parentPackage)) {
sb.insert(0, parentPackage);
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/hudson/plugins/robot/model/RobotResultTest.java
Expand Up @@ -23,6 +23,9 @@
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -327,4 +330,22 @@ public void testShouldParseTagsFromRobot4() throws Exception {
String tags = StringUtils.join(caseResult.getTags(), ",");
assertEquals("fail,tag2,tag3", tags);
}

@Test
public void testSuiteNameAttributeMightBeMissingInRobot4() throws Exception {
/**
* see more: https://issues.jenkins.io/browse/JENKINS-69807
**/
RobotParser.RobotParserCallable remoteOperation = new RobotParser.RobotParserCallable("robot4_empty_suite_name.xml", null, null);
result = remoteOperation.invoke(new File(RobotSuiteResultTest.class.getResource("robot4_empty_suite_name.xml").toURI()).getParentFile(), null);

RobotSuiteResult r = result.getSuites().iterator().next();
r = r.getChildSuites().iterator().next();
RobotCaseResult caseResult = r.getCaseResults().iterator().next();

// passing null as `thisObject` should not matter, as the name resolving fails first
// due to getName() returning `null`
caseResult.getRelativePackageName(null);

}
}
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<robot generator="Robot 4.0 (Python 3.9.13 on darwin)" generated="20221012 15:34:38.101" rpa="false" schemaversion="2">
<suite id="s1" name="Empty Suite Attribute" source="/Users/tkairi/tmp/empty_suite_attribute">
<suite id="s1-s1" source="/Users/tkairi/tmp/empty_suite_attribute/a_test_suite__.robot">
<test id="s1-s1-t1" name="TC">
<kw name="No Operation" library="BuiltIn">
<doc>Does absolutely nothing.</doc>
<status status="PASS" starttime="20221012 15:34:38.112" endtime="20221012 15:34:38.112"/>
</kw>
<status status="PASS" starttime="20221012 15:34:38.111" endtime="20221012 15:34:38.112"/>
</test>
<status status="PASS" starttime="20221012 15:34:38.111" endtime="20221012 15:34:38.112"/>
</suite>
<status status="PASS" starttime="20221012 15:34:38.102" endtime="20221012 15:34:38.112"/>
</suite>
<statistics>
<total>
<stat pass="1" fail="0" skip="0">All Tests</stat>
</total>
<tag>
</tag>
<suite>
<stat pass="1" fail="0" skip="0" id="s1" name="Empty Suite Attribute">Empty Suite Attribute</stat>
<stat pass="1" fail="0" skip="0" id="s1-s1">Empty Suite Attribute.</stat>
</suite>
</statistics>
<errors>
</errors>
</robot>

0 comments on commit 90aafd7

Please sign in to comment.