-
-
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 declaring exclusive resources for child nodes #4151
base: main
Are you sure you want to change the base?
Allow declaring exclusive resources for child nodes #4151
Conversation
c072648
to
933ef57
Compare
.../src/test/java/org/junit/platform/engine/support/descriptor/ResourceLockAnnotationTests.java
Show resolved
Hide resolved
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 good! I only found some minor things.
* <li>a test class | ||
* - test methods and nested test classes declared in the class.</li> | ||
* <li>a nested test class | ||
* - test methods declared in the nested class.</li> |
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.
* - test methods declared in the nested class.</li> | |
* - test methods and nested test classes declared in the nested class.</li> |
* - test methods and nested test classes declared in the class.</li> | ||
* <li>a nested test class | ||
* - test methods declared in the nested class.</li> | ||
* <li>a test method - considered to have no children.</li> |
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.
This fails, right? We should document that CHILDREN
cannot be used on methods.
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.
That's right. Added
|
||
Using the `target = CHILDREN` in a class-level `{ResourceLock}` annotation | ||
has the same semantics as adding an annotation with the same `value` and `mode` | ||
to each test method declared in this class. |
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.
to each test method declared in this class. | |
to each test method and nested test class declared in this class. |
has the same semantics as adding an annotation with the same `value` and `mode` | ||
to each test method declared in this class. | ||
|
||
It may improve parallelization when a test class declares a `READ` lock, |
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.
It may improve parallelization when a test class declares a `READ` lock, | |
This may improve parallelization when a test class declares a `READ` lock, |
but only a few methods hold a `READ_WRITE` lock. | ||
|
||
Tests in the following example would run in the `SAME_THREAD` if the `{ResourceLock}` | ||
doesn't have the `target = CHILDREN`. This is because the test class declares a `READ` |
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.
doesn't have the `target = CHILDREN`. This is because the test class declares a `READ` | |
didn't have `target = CHILDREN`. This is because the test class declares a `READ` |
Tests in the following example would run in the `SAME_THREAD` if the `{ResourceLock}` | ||
doesn't have the `target = CHILDREN`. This is because the test class declares a `READ` | ||
shared resource, but one test method holds a `READ_WRITE` lock, | ||
which forces the `SAME_THREAD` execution mode for all the test methods. |
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.
which forces the `SAME_THREAD` execution mode for all the test methods. | |
which would force the `SAME_THREAD` execution mode for all the test methods. |
@marcphilipp thanks for the review 🙂 Updated according to the comments |
Issue: #3102
Overview
Allow declaring "shared resources" for direct child nodes via the new
@ResourceLock(target = CHILDREN)
attribute.Using the
@ResourceLock(target = CHILDREN)
in a class-level annotation has the same semantics as adding an annotation with the samevalue
andmode
to each test method and nested test class declared in this class.This may improve parallelization when a test class declares a
READ
lock, but only a few methods hold aREAD_WRITE
lock.I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations