Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suite might not have name at all #58

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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);

}
}
Original file line number Diff line number Diff line change
@@ -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>