Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow DisplayNameGenerator to access runtime enclosing type for @Nested #4162

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

neronsoda
Copy link

This PR is supposed to resolve the Issue: #4130

Overview


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

@sbrannen sbrannen changed the title Fix DiaplayNameGenerator to access enclosing type for @Nested Allow DisplayNameGenerator to access runtime enclosing type for @Nested Nov 28, 2024
@neronsoda
Copy link
Author

It seems that some existing tests have been affected by the changes in adding throw new UnsupportedOperationException
I will keep correcting errors.
If you have any feedback, please feel free to share it.

@sbrannen
Copy link
Member

It seems that some existing tests have been affected by the changes in adding throw new UnsupportedOperationException I will keep correcting errors. If you have any feedback, please feel free to share it.

Which tests fail, and what is the error / stack trace?

Copy link
Member

@marcphilipp marcphilipp left a comment

Choose a reason for hiding this comment

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

The old methods of DisplayNameGenerator (that now throw UnsupportedOperationException) should neither be called nor implemented anymore.

Comment on lines 122 to 126
private static Supplier<String> createDisplayNameSupplierForMethod(Class<?> testClass, Method testMethod,
JupiterConfiguration configuration) {
return createDisplayNameSupplier(testClass, configuration,
generator -> generator.generateDisplayNameForMethod(testClass, testMethod));
}
Copy link
Member

Choose a reason for hiding this comment

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

This method and the one above for nested classes should no longer be used and therefore deleted.

@neronsoda
Copy link
Author

neronsoda commented Nov 30, 2024

@sbrannen
DisplayNameGenerationTests > indicativeSentencesGenerationInheritance() FAILED
Caused by: java.lang.UnsupportedOperationException: Implement generateDisplayNameForNestedClass(List<Class<?>>, Class<?>) instead
This error seems to be due to using the old method throwing an exception.
I'm going to fix the relevant codes.

@marcphilipp
Thank you for the feedback.
I'm going to find all the parts that use the old method and fix it.

I'll leave a comment here if I need additional feedback :)

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.

3 participants