Skip to content

Commit 509bc9f

Browse files
committed
refactor(reporting): improve test class/name reporting in un/quarantined list
We needed a more spaced reporting for the test lists in order to prevent confusion. We now report the class and test name separately for better clarity. Fixes MRGFY-5937
1 parent ac0f2cb commit 509bc9f

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

mergify_cli/ci/junit_processing/junit.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,15 @@ async def junit_to_spans(
194194

195195
for testcase in testsuite.findall("testcase"):
196196
classname = testcase.get("classname")
197-
if classname is not None:
198-
test_name = classname + "." + testcase.get("name", "unnamed test")
199-
else:
200-
test_name = testcase.get("name", "unnamed test")
197+
test_case_name = testcase.get("name", "unnamed test")
201198
start_time = now - int(float(testcase.get("time", 0)) * 10e9)
202199
min_start_time = min(min_start_time, start_time)
203200

204201
attributes: dict[str, str | bool] = {
205202
"test.scope": "case",
206-
"test.case.name": test_name,
207-
"code.function.name": test_name,
203+
"test.class.name": classname,
204+
"test.case.name": test_case_name,
205+
"code.function.name": test_case_name,
208206
"cicd.test.quarantined": False,
209207
}
210208

@@ -249,7 +247,7 @@ async def junit_to_spans(
249247
)
250248

251249
span = ReadableSpan(
252-
name=test_name,
250+
name=test_case_name,
253251
start_time=start_time,
254252
end_time=now,
255253
context=opentelemetry.trace.span.SpanContext(

mergify_cli/ci/junit_processing/quarantine.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,16 @@ async def check_and_update_failing_spans(
9898
if quarantined_tests_spans:
9999
click.echo(" - 🔒 Quarantined:")
100100
for qt_span in quarantined_tests_spans:
101-
click.echo(f" · {qt_span.name}")
101+
click.echo(" · Test:")
102+
click.echo(f" Class: {qt_span.attributes.get('test.class.name')}")
103+
click.echo(f" Name: {qt_span.attributes.get('test.case.name')}")
102104

103105
if non_quarantined_tests_spans:
104106
click.echo(" - ❌ Unquarantined:")
105107
for nqt_span in non_quarantined_tests_spans:
106-
click.echo(f" · {nqt_span.name}")
108+
click.echo(" · Test:")
109+
click.echo(f" Class: {nqt_span.attributes.get('test.class.name')}")
110+
click.echo(f" Name: {nqt_span.attributes.get('test.case.name')}")
107111

108112
return failing_tests_not_quarantined_count
109113

0 commit comments

Comments
 (0)