Skip to content

Conversation

@jdneo
Copy link
Member

@jdneo jdneo commented Jul 24, 2019

resolve #737

demo

By searching the annotation hierarchy, we can resolve the meta-annotation scenario.

@jdneo jdneo added this to the 0.18.3 milestone Jul 24, 2019
* @param annotationToSearch The annotation string.
* @param checkHierarchy Specify whether to search the whole annotation hierarchy.
*/
public static boolean hasAnnotation(IMember member, String annotationToSearch, boolean checkHierarchy) {
Copy link
Member

Choose a reason for hiding this comment

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

Would Inherited be more proper than hierarchy? e.g. checkInherited

Copy link
Member

Choose a reason for hiding this comment

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

includeInherited looks even better.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, actually the annotation we treated here is not inherited. That's why it is called meta-annotation.

Copy link
Member

Choose a reason for hiding this comment

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

exactly, not inherited. From the saying meta-annotation, it's annotation of an annotation, and it is, more like aggregation/combination.
Anyway, use whatever proper name you like.

Copy link
Member

@Eskibear Eskibear left a comment

Choose a reason for hiding this comment

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

LGTM.
Suggest to add test cases to guard the utitilities later.

}
for (final String annotation : this.testMethodAnnotations) {
if (TestFrameworkUtils.hasAnnotation(method, annotation)) {
if (TestFrameworkUtils.hasAnnotation(method, annotation, false /*checkHierarchy*/)) {
Copy link
Member

@Eskibear Eskibear Jul 25, 2019

Choose a reason for hiding this comment

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

Actually you might simply overload hasAnnotation, to avoid changing these statements.

boolean hasAnnotation(method, anno) {
  return hasAnnotation(method, anno, false);
}

boolean hasAnnotation(method, anno, boolean) {
 // ...
}

@jdneo jdneo merged commit 217db45 into master Aug 1, 2019
@jdneo jdneo deleted the cs/issue-737 branch August 1, 2019 03:21
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.

Support JUnit 5 Meta-Annotations and Composed Annotations

3 participants