Skip to content

Commit 628f36b

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 628f36b

File tree

3 files changed

+42
-26
lines changed

3 files changed

+42
-26
lines changed

mergify_cli/ci/junit_processing/junit.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,19 @@ async def junit_to_spans(
194194

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

204205
attributes: dict[str, str | bool] = {
205206
"test.scope": "case",
206-
"test.case.name": test_name,
207-
"code.function.name": test_name,
207+
"test.suite.name": classname,
208+
"test.case.name": test_case_name,
209+
"code.function.name": test_case_name,
208210
"cicd.test.quarantined": False,
209211
}
210212

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.suite.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.suite.name')}")
110+
click.echo(f" Name: {nqt_span.attributes.get('test.case.name')}")
107111

108112
return failing_tests_not_quarantined_count
109113

mergify_cli/tests/ci/test_junit.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ async def test_parse(
131131
},
132132
{
133133
"attributes": {
134-
"test.case.name": "Tests.Registration.testCase1",
135-
"code.function.name": "Tests.Registration.testCase1",
134+
"test.suite.name": "Tests.Registration",
135+
"test.case.name": "testCase1",
136+
"code.function.name": "testCase1",
136137
"test.case.result.status": "passed",
137138
"test.scope": "case",
138139
"test.framework": "unittest",
@@ -161,8 +162,9 @@ async def test_parse(
161162
},
162163
{
163164
"attributes": {
164-
"test.case.name": "Tests.Registration.testCase2",
165-
"code.function.name": "Tests.Registration.testCase2",
165+
"test.suite.name": "Tests.Registration",
166+
"test.case.name": "testCase2",
167+
"code.function.name": "testCase2",
166168
"test.case.result.status": "skipped",
167169
"test.scope": "case",
168170
"test.framework": "unittest",
@@ -194,8 +196,9 @@ async def test_parse(
194196
"exception.message": "invalid literal for int() with base 10: 'foobar'",
195197
"exception.stacktrace": "bip, bip, bip, error!",
196198
"exception.type": "ValueError",
197-
"test.case.name": "Tests.Registration.testCase3",
198-
"code.function.name": "Tests.Registration.testCase3",
199+
"test.suite.name": "Tests.Registration",
200+
"test.case.name": "testCase3",
201+
"code.function.name": "testCase3",
199202
"test.case.result.status": "failed",
200203
"test.scope": "case",
201204
"test.framework": "unittest",
@@ -251,8 +254,9 @@ async def test_parse(
251254
},
252255
{
253256
"attributes": {
254-
"test.case.name": "Tests.Authentication.testCase7",
255-
"code.function.name": "Tests.Authentication.testCase7",
257+
"test.suite.name": "Tests.Authentication",
258+
"test.case.name": "testCase7",
259+
"code.function.name": "testCase7",
256260
"test.case.result.status": "passed",
257261
"test.scope": "case",
258262
"test.framework": "unittest",
@@ -281,8 +285,9 @@ async def test_parse(
281285
},
282286
{
283287
"attributes": {
284-
"test.case.name": "Tests.Authentication.testCase8",
285-
"code.function.name": "Tests.Authentication.testCase8",
288+
"test.suite.name": "Tests.Authentication",
289+
"test.case.name": "testCase8",
290+
"code.function.name": "testCase8",
286291
"test.case.result.status": "passed",
287292
"test.scope": "case",
288293
"test.framework": "unittest",
@@ -314,8 +319,9 @@ async def test_parse(
314319
"exception.message": "Assertion error message",
315320
"exception.stacktrace": "Such a mess, the failure is unrecoverable",
316321
"exception.type": "AssertionError",
317-
"test.case.name": "Tests.Authentication.testCase9",
318-
"code.function.name": "Tests.Authentication.testCase9",
322+
"test.suite.name": "Tests.Authentication",
323+
"test.case.name": "testCase9",
324+
"code.function.name": "testCase9",
319325
"test.case.result.status": "failed",
320326
"test.scope": "case",
321327
"test.framework": "unittest",
@@ -348,8 +354,9 @@ async def test_parse(
348354
"exception.stacktrace": "Everything is broken, meh!\n"
349355
"With a second line!",
350356
"exception.type": "ZeroDivisionError",
351-
"test.case.name": "Tests.Permission.testCase10",
352-
"code.function.name": "Tests.Permission.testCase10",
357+
"test.suite.name": "Tests.Permission",
358+
"test.case.name": "testCase10",
359+
"code.function.name": "testCase10",
353360
"test.case.result.status": "failed",
354361
"test.scope": "case",
355362
"test.framework": "unittest",
@@ -405,8 +412,9 @@ async def test_parse(
405412
},
406413
{
407414
"attributes": {
408-
"test.case.name": "Tests.Authentication.Login.testCase4",
409-
"code.function.name": "Tests.Authentication.Login.testCase4",
415+
"test.suite.name": "Tests.Authentication.Login",
416+
"test.case.name": "testCase4",
417+
"code.function.name": "testCase4",
410418
"test.case.result.status": "passed",
411419
"test.scope": "case",
412420
"test.framework": "unittest",
@@ -438,8 +446,9 @@ async def test_parse(
438446
"exception.message": "invalid syntax",
439447
"exception.stacktrace": "bad syntax, bad!",
440448
"exception.type": "SyntaxError",
441-
"test.case.name": "Tests.Authentication.Login.testCase5",
442-
"code.function.name": "Tests.Authentication.Login.testCase5",
449+
"test.suite.name": "Tests.Authentication.Login",
450+
"test.case.name": "testCase5",
451+
"code.function.name": "testCase5",
443452
"test.case.result.status": "failed",
444453
"test.scope": "case",
445454
"test.framework": "unittest",
@@ -468,8 +477,9 @@ async def test_parse(
468477
},
469478
{
470479
"attributes": {
471-
"test.case.name": "Tests.Authentication.Login.testCase6",
472-
"code.function.name": "Tests.Authentication.Login.testCase6",
480+
"test.suite.name": "Tests.Authentication.Login",
481+
"test.case.name": "testCase6",
482+
"code.function.name": "testCase6",
473483
"test.case.result.status": "passed",
474484
"test.scope": "case",
475485
"test.framework": "unittest",

0 commit comments

Comments
 (0)