Skip to content

Commit

Permalink
Check for <testsuites> vs <testsuite> root tag. Fixes #9
Browse files Browse the repository at this point in the history
According to the JUnit XML specs:
https://www.ibm.com/support/knowledgecenter/en/SSUFAU_1.0.0/com.ibm.rsar.analysis.codereview.cobol.doc/topics/cac_useresults_junit.html

the root element in the XML is a <testsuites> tag. However some
of the test runners we've used skip that and have a single
<testsuite> tag as their root node. This causes failures for
people using some of the other test runners, e.g.

- Katalon Studio - exports with the <testsuites> tag
- Nose, py.test - export results with the <testsuite> tag
  • Loading branch information
atodorov committed Sep 20, 2019
1 parent 3381caf commit f244af9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tcms_junit_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ def parse(self, junit_xml, progress_cb=None):
self.backend.configure()

xml = JUnitXml.fromfile(junit_xml)
for xml_case in xml:
# apparently junit.xml may contain either a <testsuites> tag - Katalon Studio
if xml._tag == "testsuites":
cases = []
for suite in xml:
for case in suite:
cases.append(case)
# or directly <testsuite> (only 1) tag - nose & py.test
else:
cases = list(xml)

for xml_case in cases:
summary = "%s.%s" % (xml_case.classname, xml_case.name)

test_case = self.backend.test_case_get_or_create(summary)
Expand Down

0 comments on commit f244af9

Please sign in to comment.