Skip to content
New issue

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

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

Already on GitHub? # to your account

Inheritance support for conditional annotations #4147

Open
1 task
scordio opened this issue Nov 22, 2024 · 3 comments
Open
1 task

Inheritance support for conditional annotations #4147

scordio opened this issue Nov 22, 2024 · 3 comments

Comments

@scordio
Copy link
Contributor

scordio commented Nov 22, 2024

I faced a use case where inheritance for @EnabledIfSystemProperty would have helped for less boilerplate.

Specifically, it's a project with many test classes for integration tests that should be executed only on the CI infrastructure and specific runners. Such fine-grained control is currently achieved combining the maven-failsafe-plugin to exclude the local environment and @EnabledIfSystemProperty(named = "it.test", matches = ".+") on each test class to ensure that they are executed only under the appropriate CI jobs (the it.test property is set to different values by each CI job to tune the failsafe plugin execution further).

As the test classes already share common parts in a parent class, pulling @EnabledIfSystemProperty to the parent class would help reduce the boilerplate.

Relates to #3462 (comment).

Deliverables

  • Conditional annotations support inheritance
@marcphilipp
Copy link
Member

Thinking out loud here, I think we have at least the following options:

  1. Make the existing annotations @Inherited
  2. Add a variant for each annotation that is @Inherited
  3. Change the annotation search algorithm for test classes to check parent classes as well

Both (1) and (3) would be breaking changes. For (2), I think we could generate the @Inherited variant, and add some glue code that uses a java.lang.reflect.Proxy so the majority of the code wouldn't have to change.

Any other ideas?

@scordio
Copy link
Contributor Author

scordio commented Nov 27, 2024

Change the annotation search algorithm for test classes to check parent classes as well

To avoid the breaking change, can this be combined with a new opt-in flag for the current annotations, false by default? Something like in inherited=true or similar.

@marcphilipp
Copy link
Member

Team decision: Wait for additional interest from the community.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants