-
-
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
Allow determining exclusive resources programmatically #3889
Allow determining exclusive resources programmatically #3889
Conversation
50377ba
to
194832d
Compare
c0b3d77
to
a90636d
Compare
3e1d2a6
to
7d894c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very promising! Sorry for the late request to change the API.
junit-jupiter-api/src/main/java/org/junit/jupiter/api/parallel/ResourceLocksFrom.java
Outdated
Show resolved
Hide resolved
junit-jupiter-api/src/main/java/org/junit/jupiter/api/parallel/ResourceLocksProvider.java
Show resolved
Hide resolved
Hi @marcphilipp |
...-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/JupiterTestDescriptor.java
Outdated
Show resolved
Hide resolved
documentation/src/test/java/example/sharedresources/DynamicSharedResourcesDemo.java
Outdated
Show resolved
Hide resolved
...iter-engine/src/main/java/org/junit/jupiter/engine/descriptor/MethodBasedTestDescriptor.java
Outdated
Show resolved
Hide resolved
Issue: #2677
...iter-engine/src/main/java/org/junit/jupiter/engine/descriptor/MethodBasedTestDescriptor.java
Outdated
Show resolved
Hide resolved
.../src/test/java/org/junit/platform/engine/support/descriptor/ResourceLockAnnotationTests.java
Outdated
Show resolved
Hide resolved
Issue: #2677
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll take it from here.
documentation/src/docs/asciidoc/release-notes/release-notes-5.12.0-M1.adoc
Outdated
Show resolved
Hide resolved
documentation/src/test/java/example/sharedresources/DynamicSharedResourcesDemo.java
Outdated
Show resolved
Hide resolved
documentation/src/test/java/example/sharedresources/DynamicSharedResourcesDemo.java
Outdated
Show resolved
Hide resolved
junit-jupiter-api/src/main/java/org/junit/jupiter/api/parallel/ResourceLocksProvider.java
Outdated
Show resolved
Hide resolved
junit-jupiter-api/src/main/java/org/junit/jupiter/api/parallel/ResourceLocksProvider.java
Outdated
Show resolved
Hide resolved
junit-jupiter-api/src/main/java/org/junit/jupiter/api/parallel/ResourceLocksProvider.java
Outdated
Show resolved
Hide resolved
junit-jupiter-api/src/main/java/org/junit/jupiter/api/parallel/ResourceLocksProvider.java
Outdated
Show resolved
Hide resolved
List<ResourceLock> enclosingClassesAnnotations = getEnclosingTestClasses().stream() | ||
.map(clazz -> findRepeatableAnnotations(clazz, ResourceLock.class)) | ||
.flatMap(Collection::stream) | ||
.collect(toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be slightly better to get the registered ResourceLockProviders
from the parent test descriptor rather than collecting them again for every test and reinstantiating them but I'll take care of that in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, many method / nested class descriptors may share the same parent 👍
Thank you! |
Solves: #2677
Overview
Introduce adding
shared resources
programmatically via@ResourceLock(providers = ...)
attributewhich accepts an array of one or more classes implementing
ResourceLocksProvider
interface.It allows to add resources in runtime (immediately before starting execution on the engine level).
Resources can be distributed based on any test class / nested test class / test method attributes (e.g. package name, class / method name etc.) or any other user logic.
This approach serves as a more flexible and less verbose alternative for cases in which:
@ResourceLock(value, mode)
annotations manually may be inconvenient;I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations