-
-
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
Make core features of AnnotationUtils available to extension authors #246
Comments
@nicolaiparlog, thanks for raising this issue. You make some valid arguments. @junit-team/junit-lambda, let's discuss the options here. |
AnnotationUtils
public API
I'm working on an extension (https://github.com/selesy/uprest) to replace the defunct Restfuse project (https://github.com/eclipsesource/restfuse). Since the tests are defined declaratively, I make heavy use of annotations and also ended up writing a small utility class to retrieve annotation values. I can potentially have:
And now I'm realizing that to make the test code well-factored, I also need to detect annotations up the parent type hierarchy as well as to the super() of each method (if they're overriden). I guess that's a long-winded way of saying +1! |
@smoyer64 upREST looks really promising! Great stuff! I quite agree that we should make this functionality available to extensions. However, I'm not convinced that making |
I agree with @marcphilipp and actually already had the exact same idea... to provide a public API local to the |
Either way is fine with me ... and I certainly know the value of limited the surface area of the actual API (leaving more code as the proverbial "black box"). I think the spirit of the proposal by @nicolaiparlog would be met by exposing that functionality elsewhere. As an aside, since (at the moment) the upREST framework's two primary goals are to create dynamic tests (the example above would actually produce four tests) and to execute the tests having already sent the HTTP request and received the HTTP response, most of the work is done behind the scenes as a means of satisfying one or more MethodParameterResolvers. This involves a chaining of dependent resolvers where everything is dependent upon resolving the HTTP request even though many times it's not "injected" into the method call. In any case, I guess what I'm really looking for is a little guidance on when using the ExtensionContext is more appropriate than the MethodInvocationContext. I'd also like to extend the use of the JUnit5 @API tag to the upREST extension(s). Assuming JUnit5 users learn to "honor" the status of the API (using only maintained?), it seems like they'd understand or even expect the same from extensions. |
My intent was to gain supported access to the functionality and I am happy that you are seeing things similarly. :) I don't care much which way it happens and absolutely see your point to concentrate API access via execution contexts instead of simply "making stuff public". |
I agree with @marcphilipp and @sbrannen that it might be wise to hide the implementation of the annotation utils properly. We also might want to expose the functionality in an adequate way to prevent people from reinventing the wheel or even worse from using internal stuff reflectively... @smoyer64 first of all, thanks for working on such an interesting application of JUnit5 features. |
in progress - see draft PR #651 |
Fixes #246 by publishing useful internal helper methods via an API facade. At the moment, only annotation-related helpers are included. The ExtensionContext.Util interface might grow in the future.
see #352 (comment) |
While implementing extensions it is common to look for annotations. The easiest way to do this properly (i.e. including repeatable and meta-annotations) seems to be
AnnotationUtils
. It is currently marked as internal API.Annotations and especially meta-annotations are a pillar of JUnit 5's extensibility. Being able to freely compose existing annotations according to ones own requirements will be a great boost for customizations. It would be counter-intuitive if third-party extensions would not compose as well. They are hence required to use the same look-up logic as official annotations.
The easiest way to do this is to encourage using the same utility to find annotations.
The text was updated successfully, but these errors were encountered: