Skip to content

Commit

Permalink
Added proper uid to imported testcases (#1100)
Browse files Browse the repository at this point in the history
Added proper uid to imported testcases, so the ui navigation can work with them properly.

Co-authored-by: Krisztian Notaisz <[email protected]>
  • Loading branch information
kn-ms and kn-ms authored Jun 11, 2024
1 parent 5a1e45e commit 826509c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/newsfragments/2966_changed.imported_reports_uids.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Imported unittest reports (gtest, cppunit, junit) are now properly rendering the error output in the report viewer.
3 changes: 3 additions & 0 deletions testplan/importers/cppunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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():
Expand All @@ -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():
Expand Down
6 changes: 5 additions & 1 deletion testplan/importers/gtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 5 additions & 1 deletion testplan/importers/junit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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():
Expand All @@ -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(
Expand Down
6 changes: 5 additions & 1 deletion testplan/importers/suitesresults.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 826509c

Please sign in to comment.