Skip to content

Restore reportNameSuffix in testcase classname attribute (regression since 3.5.4)#3265

Open
UtkarshSinghChauhan wants to merge 4 commits intoapache:masterfrom
UtkarshSinghChauhan:fix-testcase-classname-suffix
Open

Restore reportNameSuffix in testcase classname attribute (regression since 3.5.4)#3265
UtkarshSinghChauhan wants to merge 4 commits intoapache:masterfrom
UtkarshSinghChauhan:fix-testcase-classname-suffix

Conversation

@UtkarshSinghChauhan
Copy link
Copy Markdown

This pull request addresses a regression introduced in version 3.5.4 where the configured reportNameSuffix is no longer appended to the classname attribute in the generated XML report.
In version 3.5.3, the StatelessXmlReporter used report.getSourceName(reportNameSuffix) when generating the element. This ensured that any configured suffix (for example, (Linux)) was correctly included in the classname attribute of the XML output.
However, in 3.5.4 the logic was modified to prefer report.getSourceText(). While this change may have been intended to improve source handling, it unintentionally bypasses the reportNameSuffix logic. As a result, the suffix is omitted from the XML report even when it is explicitly configured.
For example:
Expected behavior (3.5.3):
<testcase classname="com.example.MoneyTest(Linux)" ... />

Actual behavior (3.5.4):
<testcase classname="com.example.MoneyTest" ... />

This patch restores the previous behavior by ensuring that report.getSourceName(reportNameSuffix) is used so that the configured suffix is consistently preserved in the XML output.
The change was verified by:
Building the project with mvn clean install
Running tests successfully
Creating a sample project to confirm that the generated XML report includes the expected suffix

This restores backward compatibility and aligns the behavior with user expectations when reportNameSuffix is configured.

@slawekjaranowski slawekjaranowski linked an issue Feb 17, 2026 that may be closed by this pull request
String className = phrasedClassName
? report.getReportSourceName(reportNameSuffix)
: report.getSourceText() != null ? report.getSourceText() : report.getSourceName(reportNameSuffix);
: report.getSourceName(reportNameSuffix);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out.

My change does not reintroduce the issue from SUREFIRE-2298.
The goal of this change is to restore reportNameSuffix in the
testcase classname attribute, which was lost after that change.

Using report.getSourceName(reportNameSuffix) still keeps the
correct behavior for JUnit 5 nested classes while restoring
the suffix in the XML report classname.

I will also add an integration test to verify this behavior.
Sorry for the late reply.

@slawekjaranowski
Copy link
Copy Markdown
Member

do we have any test for it? 🤔

@olamy
Copy link
Copy Markdown
Member

olamy commented Feb 17, 2026

do we have any test for it? 🤔

I agree
@UtkarshSinghChauhan please provide some IT test for such change

Copy link
Copy Markdown
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a test to prevent regressions from happening again.

Copy link
Copy Markdown
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to merge in master

@UtkarshSinghChauhan
Copy link
Copy Markdown
Author

@elharo
Merged latest master into my branch and resolved conflicts. Please review again.

@elharo
Copy link
Copy Markdown
Contributor

elharo commented Apr 8, 2026

tests are failing, might be related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing suffix in testcase classname XML report

4 participants