From 826509c36cb3fea1fea1052db6fc45afd675a992 Mon Sep 17 00:00:00 2001 From: Krisztian Notaisz <61833595+kn-ms@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:33:59 +0200 Subject: [PATCH] Added proper uid to imported testcases (#1100) Added proper uid to imported testcases, so the ui navigation can work with them properly. Co-authored-by: Krisztian Notaisz --- doc/newsfragments/2966_changed.imported_reports_uids.rst | 1 + testplan/importers/cppunit.py | 3 +++ testplan/importers/gtest.py | 6 +++++- testplan/importers/junit.py | 6 +++++- testplan/importers/suitesresults.py | 6 +++++- 5 files changed, 19 insertions(+), 3 deletions(-) create mode 100755 doc/newsfragments/2966_changed.imported_reports_uids.rst diff --git a/doc/newsfragments/2966_changed.imported_reports_uids.rst b/doc/newsfragments/2966_changed.imported_reports_uids.rst new file mode 100755 index 000000000..bb76ec3c6 --- /dev/null +++ b/doc/newsfragments/2966_changed.imported_reports_uids.rst @@ -0,0 +1 @@ +Imported unittest reports (gtest, cppunit, junit) are now properly rendering the error output in the report viewer. diff --git a/testplan/importers/cppunit.py b/testplan/importers/cppunit.py index b3b62a1f9..0750e7ac8 100644 --- a/testplan/importers/cppunit.py +++ b/testplan/importers/cppunit.py @@ -9,6 +9,7 @@ from lxml.builder import E from lxml.objectify import Element +from testplan.common.utils.strings import uuid4 from testplan.importers.base import ThreePhaseFileImporter, T from testplan.importers.suitesresults import SuitesResult from testplan.report import ( @@ -133,6 +134,7 @@ def _process_data(self, data: Element) -> List[TestGroupReport]: suite_report = TestGroupReport( name=suite_name, category=ReportCategories.TESTSUITE, + uid=uuid4(), ) for testcase in suite.getchildren(): @@ -144,6 +146,7 @@ def _process_data(self, data: Element) -> List[TestGroupReport]: testcase_prefix = testcase_classname.split(".")[-1] testcase_report = TestCaseReport( name="{}::{}".format(testcase_prefix, testcase_name), + uid=uuid4(), ) if not testcase.getchildren(): diff --git a/testplan/importers/gtest.py b/testplan/importers/gtest.py index 4e95254c6..1516b325a 100644 --- a/testplan/importers/gtest.py +++ b/testplan/importers/gtest.py @@ -6,6 +6,7 @@ from lxml import objectify from lxml.objectify import Element +from testplan.common.utils.strings import uuid4 from testplan.importers.base import T, ThreePhaseFileImporter from testplan.importers.suitesresults import SuitesResult from testplan.report import ( @@ -51,13 +52,16 @@ def _process_data(self, data: Element) -> List[TestGroupReport]: suite_report = TestGroupReport( name=suite_name, category=ReportCategories.TESTSUITE, + uid=uuid4(), ) suite_has_run = False for testcase in suite.getchildren(): testcase_name = testcase.attrib["name"] - testcase_report = TestCaseReport(name=testcase_name) + testcase_report = TestCaseReport( + name=testcase_name, uid=uuid4() + ) if not testcase.getchildren(): assertion_obj = RawAssertion( diff --git a/testplan/importers/junit.py b/testplan/importers/junit.py index ec3146152..ec4d64563 100644 --- a/testplan/importers/junit.py +++ b/testplan/importers/junit.py @@ -16,6 +16,7 @@ ) from testplan.testing.multitest.entries.assertions import RawAssertion from testplan.testing.multitest.entries.schemas.base import registry +from ..common.utils.strings import uuid4 class JUnitImportedResult(SuitesResult): @@ -53,6 +54,7 @@ def _process_data(self, data: Element) -> List[TestGroupReport]: suite_report = TestGroupReport( name=suite_name, category=ReportCategories.TESTSUITE, + uid=uuid4(), ) for element in suite.getchildren(): @@ -76,7 +78,9 @@ def _process_data(self, data: Element) -> List[TestGroupReport]: else: case_report_name = f"{case_class}::{case_name}" - case_report = TestCaseReport(name=case_report_name) + case_report = TestCaseReport( + name=case_report_name, uid=uuid4() + ) if not element.getchildren(): assertion = RawAssertion( diff --git a/testplan/importers/suitesresults.py b/testplan/importers/suitesresults.py index b1f382035..9ba56dd57 100644 --- a/testplan/importers/suitesresults.py +++ b/testplan/importers/suitesresults.py @@ -1,5 +1,6 @@ from typing import List +from testplan.common.utils.strings import uuid4 from testplan.importers import ImportedResult from testplan.report import TestGroupReport, TestReport, ReportCategories @@ -30,11 +31,14 @@ def as_test_report(self) -> TestReport: :return: a plan report contains a single test having all the returned suite results """ - report = TestReport(name=self.name, description=self.description) + report = TestReport( + name=self.name, description=self.description, uid=uuid4() + ) test_report = TestGroupReport( name=self.name, category=self.REPORT_CATEGORY, description=self.description, + uid=uuid4(), ) for suite_report in self.results():