-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Check for DisplayNameGeneration annotations on runtime enclosing types #4268
Check for DisplayNameGeneration annotations on runtime enclosing types #4268
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general the PR looks good, and the tests demonstrate the expected results. 👍
I've asked a few questions and requested a few minor changes.
Regarding the internal refactoring in DisplayNameUtils
, I'll have to review that later in an IDE.
documentation/src/docs/asciidoc/release-notes/release-notes-5.12.0-M1.adoc
Outdated
Show resolved
Hide resolved
junit-jupiter-api/src/main/java/org/junit/jupiter/api/DisplayNameGenerator.java
Outdated
Show resolved
Hide resolved
junit-platform-commons/src/main/java/org/junit/platform/commons/support/AnnotationSupport.java
Outdated
Show resolved
Hide resolved
junit-platform-commons/src/main/java/org/junit/platform/commons/support/AnnotationSupport.java
Outdated
Show resolved
Hide resolved
junit-platform-commons/src/main/java/org/junit/platform/commons/support/SearchOption.java
Outdated
Show resolved
Hide resolved
junit-platform-commons/src/main/java/org/junit/platform/commons/support/SearchOption.java
Outdated
Show resolved
Hide resolved
@@ -37,7 +39,11 @@ public enum SearchOption { | |||
* Search the inheritance hierarchy as with the {@link #DEFAULT} search option | |||
* but also search the {@linkplain Class#getEnclosingClass() enclosing class} | |||
* hierarchy for <em>inner classes</em> (i.e., a non-static member classes). | |||
* | |||
* @deprecated because it's preferable to inspect the runtime enclosing | |||
* types of a class rather than where they are declared. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I certainly agree with that sentiment, developers and libraries that use AnnotationSupport
often will not have access to the runtime enclosing types. Typically only JUnit internals have access to those.
So, I am a bit reluctant to deprecate this feature.
However, if we deprecate it and nobody complains, then I suppose it's fine. 😇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I certainly agree with that sentiment, developers and libraries that use
AnnotationSupport
often will not have access to the runtime enclosing types. Typically only JUnit internals have access to those.
Jupiter extension authors can access them via ExtensionContext.getRequiredTestClass()
, recursively, or get them from ExtensionContext.getRequiredTestInstances()
by calling Object.getClass()
on each instance.
I checked the original issue and didn't find an actual user request. Therefore, since this was the only place we used it, I deprecated the method. We can always undeprecate it if anyone complains. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also considered the fact that Jupiter extension authors have a way to access that information, so I was thinking more about the general purpose nature of the utilities in AnnotationSupport
for other testing frameworks, engines, etc.
I checked the original issue and didn't find an actual user request. Therefore, since this was the only place we used it, I deprecated the method. We can always undeprecate it if anyone complains. WDYT?
Yep, as I mentioned before.... if nobody complains, it's fine. 👍
junit-jupiter-api/src/main/java/org/junit/jupiter/api/DisplayNameGenerator.java
Outdated
Show resolved
Hide resolved
junit-jupiter-api/src/main/java/org/junit/jupiter/api/DisplayNameGenerator.java
Outdated
Show resolved
Hide resolved
dd5c4a0
to
3265d58
Compare
Co-authored-by: Sam Brannen <[email protected]>
Co-authored-by: Sam Brannen <[email protected]>
56ce4ff
to
da61c32
Compare
Resolves #4131.
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations