From f244af9c25625b416dd1b9e27730912aed4f1313 Mon Sep 17 00:00:00 2001 From: "Mr. Senko" Date: Fri, 20 Sep 2019 13:01:43 +0300 Subject: [PATCH] Check for vs root tag. Fixes #9 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 tag. However some of the test runners we've used skip that and have a single tag as their root node. This causes failures for people using some of the other test runners, e.g. - Katalon Studio - exports with the tag - Nose, py.test - export results with the tag --- tcms_junit_plugin/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tcms_junit_plugin/__init__.py b/tcms_junit_plugin/__init__.py index 43a8db2..7731ce8 100644 --- a/tcms_junit_plugin/__init__.py +++ b/tcms_junit_plugin/__init__.py @@ -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 tag - Katalon Studio + if xml._tag == "testsuites": + cases = [] + for suite in xml: + for case in suite: + cases.append(case) + # or directly (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)