Skip to content

Conversation

@raccoonback
Copy link
Contributor

Fixes #5155

This PR enables the use of @ResourceLock on classes annotated with @ClassTemplate.

Background

Currently, applying @ResourceLock to a @ClassTemplate class results in the following failure:

Dynamic test descriptors must not declare exclusive resources

This happens because ClassTemplateInvocationTestDescriptor#getExclusiveResources() returns a non-empty set, causing the invocation descriptor to report exclusive resources even though the enclosing ClassTemplateTestDescriptor already collects and exposes them at the class level.

Summary of Changes

  • Override ClassTemplateInvocationTestDescriptor#getExclusiveResources() to always return an empty set.

    • Class-level exclusive resources are already managed by ClassTemplateTestDescriptor, so the invocation descriptor should not contribute additional exclusive resources.
  • Add a dedicated test classTemplateWithResourceLockExecutesSuccessfully() to verify that:

    • A @ClassTemplate class annotated with @ResourceLock executes successfully.
    • Both test and container events complete without errors.

I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Class templates should be able to declare @ResourceLock

2 participants