Skip to content

[SUREFIRE-2101] - Fixes 'null' phrased test names with JUnit5 without @DisplayName#549

Merged
slawekjaranowski merged 1 commit intoapache:masterfrom
ascopes:SUREFIRE-2101
Dec 27, 2022
Merged

[SUREFIRE-2101] - Fixes 'null' phrased test names with JUnit5 without @DisplayName#549
slawekjaranowski merged 1 commit intoapache:masterfrom
ascopes:SUREFIRE-2101

Conversation

@ascopes
Copy link
Copy Markdown
Contributor

@ascopes ascopes commented Jun 19, 2022

When phrased test names are enabled, but an annotation such as DisplayName
in JUnit5 is missing from the test, the output to the console will now
fall back to using the original name rather than naming the test
'null'.

This amends this behaviour to provide a more meaningful name in these scenarios,
which can be important when migrating a large code base over to using
phrased names incrementally.

An example of the existing output which can be problematic:

image


To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

  • I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0

  • As of Sunday 19th June 2022, I have submitted a signed copy of the Apache ICLA to mailto:secretary@apache.org in PDF form.

When phrased test names are enabled, but an annotation such as DisplayName
in JUnit5 is missing from the test, the output to the console will now
fall back to using the original name rather than naming the test
'null'.
@andpab
Copy link
Copy Markdown
Contributor

andpab commented Dec 22, 2022

This pull request fixes the issue for the JUnit5StatelessTestsetInfoReporter, but not for the JUnit5ConsoleOutputReporter.

You can see that in the output of the JUnitPlatformEnginesIT#testJupiterEngineWithDisplayNames. It still has "Running null" in it with your fix.

The reason it doesn't work there is that you adjusted the behaviour for the CategorizedReportEntry and the WrappedReportEntry, but not for the SimpleReportEntry.

I've made an alternative pull request #587 that fixes it in a single place, the TestSetStats class. I think that's more robust.

@slawekjaranowski slawekjaranowski added the bug Something isn't working label Dec 27, 2022
@slawekjaranowski slawekjaranowski merged commit 61f03c6 into apache:master Dec 27, 2022
@slawekjaranowski
Copy link
Copy Markdown
Member

@ascopes thanks
I changed commit message to contains issue number in square brackets 😄

@jira-importer
Copy link
Copy Markdown

Resolve #2836

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants