-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Allow @ResourceLock on @ClassTemplate classes #5176
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
base: main
Are you sure you want to change the base?
Allow @ResourceLock on @ClassTemplate classes #5176
Conversation
Fixes junit-team#5155 Signed-off-by: raccoonback <[email protected]>
|
@marcphilipp |
|
|
||
| @Test | ||
| void classTemplateWithResourceLockExecutesSuccessfully() { | ||
| var results = executeTestsForClass(ClassTemplateWithResourceLockTestCase.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.
I think we should also verify that the discovered TestDescriptor.getExclusiveResources() return the expected Set<ExclusiveResource> for the class template.
You can do that by calling discoverTestsForClass(ClassTemplateWithResourceLockTestCase.class) and calling getEnginesDescriptor() which will have a single child: the class template descriptor.
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.
@marcphilipp
As suggested, I’ve added the classTemplateWithResourceLockCollectsExclusiveResources test.
Signed-off-by: raccoonback <[email protected]>
659c7ea to
ea7cfc8
Compare
|
@marcphilipp |
Fixes #5155
This PR enables the use of
@ResourceLockon classes annotated with@ClassTemplate.Background
Currently, applying
@ResourceLockto a@ClassTemplateclass results in the following failure:This happens because
ClassTemplateInvocationTestDescriptor#getExclusiveResources()returns a non-empty set, causing the invocation descriptor to report exclusive resources even though the enclosingClassTemplateTestDescriptoralready collects and exposes them at the class level.Summary of Changes
Override
ClassTemplateInvocationTestDescriptor#getExclusiveResources()to always return an empty set.ClassTemplateTestDescriptor, so the invocation descriptor should not contribute additional exclusive resources.Add a dedicated test
classTemplateWithResourceLockExecutesSuccessfully()to verify that:@ClassTemplateclass annotated with@ResourceLockexecutes successfully.I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@APIannotations