Skip to content

Commit

Permalink
[FIXED JENKINS-6545] support nested test suites
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Mar 30, 2011
1 parent 260f8f2 commit 4129ac5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -68,6 +68,9 @@
<li class=rfe>
Performance: Specify image sizes for faster page loading
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-9182">issue 9182</a>)
<li class=rfe>
Support nested testsuites in the JUnit test result
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-6545">issue 6545</a>)
<li class=rfe>
Added an extension point to allow associating custom properties with views.
<li class=rfe>
Expand Down
19 changes: 11 additions & 8 deletions core/src/main/java/hudson/tasks/junit/SuiteResult.java
Expand Up @@ -101,18 +101,21 @@ static List<SuiteResult> parse(File xmlReport, boolean keepLongStdio) throws Doc
Document result = saxReader.read(xmlReport);
Element root = result.getRootElement();

if(root.getName().equals("testsuites")) {
// multi-suite file
for (Element suite : (List<Element>)root.elements("testsuite"))
r.add(new SuiteResult(xmlReport, suite, keepLongStdio));
} else {
// single suite file
r.add(new SuiteResult(xmlReport, root, keepLongStdio));
}
parseSuite(xmlReport,keepLongStdio,r,root);

return r;
}

private static void parseSuite(File xmlReport, boolean keepLongStdio, List<SuiteResult> r, Element root) throws DocumentException, IOException {
// nested test suites
for (Element suite : (List<Element>)root.elements("testsuite"))
parseSuite(xmlReport, keepLongStdio, r, suite);

// child test cases
if (root.element("testcase")!=null)
r.add(new SuiteResult(xmlReport, root, keepLongStdio));
}

/**
* @param xmlReport
* A JUnit XML report file whose top level element is 'testsuite'.
Expand Down

0 comments on commit 4129ac5

Please sign in to comment.