-
-
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
Support @ExtendWith at package level and module level #1986
Comments
...and also support ElementType.MODULE -- I can't find an open issue for supporting modules -- but I'm sure we discussed before. |
👍 One more alternative would be to allow whitelisting the specific extension that would be automatically discovered:
This would eliminate my concern that extensions from deep in my dependency graph could suddenly start affecting my tests after a version upgrade (as the whitelist would be fully code-reviewable). |
The team has debated allowing extension registration at the package level several times but never decided in favor of it. The same applies to registration at the module level. The general consensus has been that it's "too magical" and non-intuitive for the average developer. One of the challenges is that it's difficult to navigate to the package level configuration. At least in Eclipse, you cannot control-click on a package name to navigate to it's |
I'm actually in favor of that and have suggested it previously. I think that would be a useful feature in general. |
@sbrannen I'd be fine with either solution. In my assessment of the 'magicness' of the various solutions, I think the whitelisting system prop is marginally more magic:
|
Although JUnit Platform configuration parameters can be set via a JVM system property, I'd say that's a worst practice for a parameter like this one. For this kind of config param, the best practice is to declare it in That way it's in version control and honored in the build and by the IDE. So for me, that's not very magical. |
That's why I like this solution. Perhaps we may support both? |
Oh the |
@iamdanfox Would you mind changing the title and description to describe adding the new config parameter? |
We should find some synergies between the proposal here and #1990. |
...I really missed the |
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. Thank you for your contribution. |
This issue has been automatically closed due to inactivity. If you have a good use case for this feature, please feel free to reopen the issue. |
Context
I've written an extension which deterministically 'shards' my tests to ensure they run on exactly one CircleCI node (by hashing the name into CIRCLE_NODE_TOTAL buckets), allowing me to dial up parallelism and make my builds go faster.
However, it's kinda annoying having to add my annotation
@CircleCiSharding
to every single test class. I considered using the automatic registration functionality (-Djunit.jupiter.extensions.autodetection.enabled=true
), but I don't like the risk that some other obscure test dependency will then magically start applying its own extension to my tests. I'd prefer to retain 100% control of exactly what I enable, it's just quite verbose with annotations on every class at the moment.Another option is to have a single TestBase which all other tests inherit from, but it's very easy to accidentally forget to use this when writing a new test.
Proposal
My suggestion would be to allow people to write a
package-info.java
:I'm imagining this would apply the extension to all tests within this package. This satisfies my goals because:
@CircleCiSharding
annotationThe text was updated successfully, but these errors were encountered: