Inherited test methods don't support their annotations (fixes #1032)#1033
Open
ingvard wants to merge 9 commits intoallure-framework:mainfrom
Open
Inherited test methods don't support their annotations (fixes #1032)#1033ingvard wants to merge 9 commits intoallure-framework:mainfrom
ingvard wants to merge 9 commits intoallure-framework:mainfrom
Conversation
baev
approved these changes
Apr 12, 2024
baev
requested changes
Jun 4, 2024
| import java.util.function.Consumer; | ||
| import java.util.stream.Stream; | ||
|
|
||
| public final class ReflectionUtils { |
| import java.util.stream.Stream; | ||
|
|
||
| public final class ReflectionUtils { | ||
| private ReflectionUtils() { |
Member
There was a problem hiding this comment.
add throw new IllegalStateException("Do not instance");
| */ | ||
| public static Set<Label> getLabels(final AnnotatedElement annotatedElement) { | ||
| return getLabels(annotatedElement.getAnnotations()); | ||
| return getLabels(getAllAnnotations(annotatedElement)); |
Member
There was a problem hiding this comment.
should be added to getLinks method as well
baev
requested changes
Jun 4, 2024
Member
baev
left a comment
There was a problem hiding this comment.
Found a bug:
public interface First {
default void a() {
}
}
public interface Second extends First {
default void b() {
}
}then ReflectionUtils.getAllDeclaredMethods(Second.class) will produce duplicate results:
public default void Second.b(),
public default void First.a(),
public default void First.a()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #1032
Context
The
getTestMethodmethod in theio.qameta.allure.junitplatform.AllureJunitPlatformUtilsclass doesn't function as expected for tests that are inherited. This is because it usesaClass.getDeclaredMethods(), which only operates on the current instance and does not include methods that are inherited. This can cause issues with annotations related to methods, such as descriptions and others.Revision 1
In this revision, I used the
aClass.getMethods()that returns all public methods on a checking class.Revision 2
However, revision 1 covers one of the test cases when all test methods are public. It doesn't work when:
In short, I have to implement two methods placed into
ReflectionUtilsto recursively collect method and annotation information. These methods are designed as simplified logic oforg.springframework.data.util.ReflectionUtilsspecifically for our needs.Checklist