Skip to content

Commit f5559d4

Browse files
committed
refactor(reporting): handle case where classname is equal to test_case_name
In some cases, the classname can be equal to the test_case_name, which leads us to create a test_name with double identical values concatenated. To avoid this, we introduced a new clause. Fixes MRGFY-5937
1 parent ac0f2cb commit f5559d4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

mergify_cli/ci/junit_processing/junit.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ async def junit_to_spans(
149149
is_remote=False,
150150
)
151151

152+
153+
152154
session_span = ReadableSpan(
153155
name="test session",
154156
context=session_context,
@@ -176,6 +178,8 @@ async def junit_to_spans(
176178
is_remote=False,
177179
)
178180

181+
182+
179183
testsuite_span = ReadableSpan(
180184
name=suite_name,
181185
context=testsuite_context,
@@ -194,10 +198,14 @@ async def junit_to_spans(
194198

195199
for testcase in testsuite.findall("testcase"):
196200
classname = testcase.get("classname")
197-
if classname is not None:
198-
test_name = classname + "." + testcase.get("name", "unnamed test")
201+
test_case_name = testcase.get("name", "unnamed test")
202+
203+
# In some cases classname is equal to test_case_name, so we check to avoid redundancy.
204+
# e.g. cypress component failure error
205+
if classname is not None and classname != test_case_name:
206+
test_name = classname + ". " + test_case_name
199207
else:
200-
test_name = testcase.get("name", "unnamed test")
208+
test_name = test_case_name
201209
start_time = now - int(float(testcase.get("time", 0)) * 10e9)
202210
min_start_time = min(min_start_time, start_time)
203211

@@ -248,6 +256,9 @@ async def junit_to_spans(
248256
status_code=opentelemetry.trace.StatusCode.OK,
249257
)
250258

259+
260+
261+
251262
span = ReadableSpan(
252263
name=test_name,
253264
start_time=start_time,

0 commit comments

Comments
 (0)