diff --git a/.travis.yml b/.travis.yml index 9c6836e..0bf2795 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,8 @@ env: - MAKE=ci - MAKE=check-build install: - - pip install -r devel.txt + - pip install -U pip + - pip install -U -r devel.txt script: - make $MAKE diff --git a/requirements.txt b/requirements.txt index c6d163c..0203bc0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -junitparser==1.6.3 +junitparser==2.0.0 tcms-api==8.6.0 diff --git a/tcms_junit_plugin/__init__.py b/tcms_junit_plugin/__init__.py index 318d0f1..75149f7 100644 --- a/tcms_junit_plugin/__init__.py +++ b/tcms_junit_plugin/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Alexander Todorov +# Copyright (c) 2019-2021 Alexander Todorov # Licensed under the GPLv3: https://www.gnu.org/licenses/gpl.html @@ -29,30 +29,35 @@ def parse(self, junit_xml, progress_cb=None): summary = "%s.%s" % (xml_case.classname, xml_case.name) test_case, _ = self.backend.test_case_get_or_create(summary) - test_case_id = test_case['id'] - - self.backend.add_test_case_to_plan(test_case_id, + self.backend.add_test_case_to_plan(test_case['id'], self.backend.plan_id) test_execution_id = self.backend.add_test_case_to_run( - test_case_id, + test_case['id'], self.backend.run_id) comment = 'Result recorded via Kiwi TCMS junit.xml-plugin' - if xml_case.result is None: + if not xml_case.result: status_id = self.backend.get_status_id('PASSED') - if isinstance(xml_case.result, Failure): - status_id = self.backend.get_status_id('FAILED') - comment = xml_case.result.tostring() - - if isinstance(xml_case.result, Error): - status_id = self.backend.get_status_id('ERROR') - comment = xml_case.result.tostring() - - if isinstance(xml_case.result, Skipped): - status_id = self.backend.get_status_id('WAIVED') - comment = xml_case.result.message + # note: since junitpartser v2.0 the result attribute holds + # a list of values b/c pytest can produce files which contain + # multiple results for the same test case. We take the first! + for result in xml_case.result: + if isinstance(result, Failure): + status_id = self.backend.get_status_id('FAILED') + comment = result.tostring() + break + + if isinstance(result, Error): + status_id = self.backend.get_status_id('ERROR') + comment = result.tostring() + break + + if isinstance(result, Skipped): + status_id = self.backend.get_status_id('WAIVED') + comment = result.message + break self.backend.update_test_execution(test_execution_id, status_id,