Restore reportNameSuffix in testcase classname attribute (regression since 3.5.4)#3265
Conversation
… from 3.5.3 to 3.5.4)
| String className = phrasedClassName | ||
| ? report.getReportSourceName(reportNameSuffix) | ||
| : report.getSourceText() != null ? report.getSourceText() : report.getSourceName(reportNameSuffix); | ||
| : report.getSourceName(reportNameSuffix); |
There was a problem hiding this comment.
There was a problem hiding this comment.
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.
|
do we have any test for it? 🤔 |
I agree |
elharo
left a comment
There was a problem hiding this comment.
This needs a test to prevent regressions from happening again.
…skipped testcases are written to XML
elharo
left a comment
There was a problem hiding this comment.
you need to merge in master
|
@elharo |
|
tests are failing, might be related |
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.