diff --git a/components/collector/src/metric_collectors/test_cases.py b/components/collector/src/metric_collectors/test_cases.py index 7991afc360..810bd7cbe0 100644 --- a/components/collector/src/metric_collectors/test_cases.py +++ b/components/collector/src/metric_collectors/test_cases.py @@ -59,8 +59,9 @@ class TestCases(MetricCollector): "timeout": "errored", "warning": "errored", } - # Regular expression to identify test case ids in entity attributes: - TEST_CASE_KEY_RE = re.compile(r"\w+\-\d+") + # Regular expression to identify test case ids in entity attributes. Matches identifiers of the form BAR-123, + # while ensuring they are not part of longer identifiers such as FOO-BAR-123 or BAR-123-456: + TEST_CASE_KEY_RE = re.compile(r"(? bool: def __entity(test: Element, result: str, namespaces: Namespaces) -> Entity: """Transform a test case into a test entity.""" name = test.attrib["name"] - for category in test.findall(".//ns:TestCategoryItem", namespaces): - if match := re.search(TestCases.TEST_CASE_KEY_RE, category.attrib["TestCategory"]): - name += f" ({match[0]})" - break + category_items = test.findall(".//ns:TestCategoryItem", namespaces) + categories = [item.attrib["TestCategory"] for item in category_items] + matches = [match[0] for category in categories if (match := re.search(TestCases.TEST_CASE_KEY_RE, category))] + if matches: + name += f" ({', '.join(sorted(matches))})" key = test.attrib["id"] return Entity(key=key, name=name, test_result=result) diff --git a/components/collector/tests/source_collectors/visual_studio_trx/base.py b/components/collector/tests/source_collectors/visual_studio_trx/base.py index 23d8b34061..f8ed68539f 100644 --- a/components/collector/tests/source_collectors/visual_studio_trx/base.py +++ b/components/collector/tests/source_collectors/visual_studio_trx/base.py @@ -41,9 +41,15 @@ class VisualStudioTRXCollectorTestCase(SourceCollectorTestCase): - - - + + + + + + + + + Unreleased" is replaced by the release/release.py script with the new release version and release date. --> +## [Unreleased] + +### Fixed + +- When measuring test cases with Visual Studio TRX as source, search all test category items for test case ids, instead of cutting the search short after the first match. Fixes [#10460](https://github.com/ICTU/quality-time/issues/10460). + ## v5.20.0 - 2024-12-05 ### Added