Skip to content

Commit

Permalink
Fix generating XML for polarion with not passed tests (red-hat-data-s…
Browse files Browse the repository at this point in the history
  • Loading branch information
kornys authored and Shilpa Chugh committed Nov 27, 2023
1 parent 400da2b commit 724e6a5
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ods_ci/utils/scripts/polarion/xunit_add_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from copy import deepcopy
from xml.dom import minidom
import os
from junitparser import JUnitXml, TestCase, TestSuite
from junitparser import JUnitXml, TestCase, TestSuite, Failure, Error, Skipped
import yaml


Expand Down Expand Up @@ -191,6 +191,23 @@ def restructure_xml_for_polarion(src_xunit_xml_file, xunit_xml_file_restructured
tc = TestCase()
tc.name = suite.name
tc.time = suite.time

if not suite.is_passed:
if isinstance(suite.result[0], Failure):
f = Failure()
f.type = suite.result[0].type
f.message = suite.result[0].message
tc.append(f)
elif isinstance(suite.result[0], Error):
e = Error()
e.type = suite.result[0].type
e.message = suite.result[0].message
tc.append(e)
elif suite.is_skipped:
s = Skipped()
s.type = suite.result[0].type
s.message = suite.result[0].message
tc.append(s)
xml_testsuite.append(tc)
xml_testsuites.append(xml_testsuite)
xml_testsuites.write(xunit_xml_file_restructured, pretty=True)
Expand Down

0 comments on commit 724e6a5

Please sign in to comment.