Skip to content

Allow @ResourceLock on @ClassTemplate classes#5176

Merged
marcphilipp merged 4 commits intojunit-team:mainfrom
raccoonback:5155-fix-exclusive-resources-for-class-template
Dec 7, 2025
Merged

Allow @ResourceLock on @ClassTemplate classes#5176
marcphilipp merged 4 commits intojunit-team:mainfrom
raccoonback:5155-fix-exclusive-resources-for-class-template

Conversation

@raccoonback
Copy link
Copy Markdown
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

@raccoonback
Copy link
Copy Markdown
Contributor Author

@marcphilipp
Hello.
I'd appreciate it if you could review this PR.

@mpkorstanje mpkorstanje modified the milestones: 6.0.2, 6.1.0-M2 Nov 28, 2025
@raccoonback raccoonback force-pushed the 5155-fix-exclusive-resources-for-class-template branch from 659c7ea to ea7cfc8 Compare December 1, 2025 03:18
@raccoonback
Copy link
Copy Markdown
Contributor Author

@marcphilipp
Hello.
I’ve applied the review feedback.

@raccoonback
Copy link
Copy Markdown
Contributor Author

@marcphilipp
Hello.
I've reflect it.
Please check this PR. 😀😃

@marcphilipp marcphilipp changed the title Allow @ResourceLock on @ClassTemplate classes Allow @ResourceLock on @ClassTemplate classes Dec 7, 2025
@testlens-app
Copy link
Copy Markdown

testlens-app Bot commented Dec 7, 2025

✅ All tests passed ✅

⚠️ TestLens detected flakiness ⚠️

Test Summary

Check Task Test Runs
CI / macOS :jupiter-tests:test SeparateThreadTimeoutInvocation > throws timeout exception when timeout duration is exceeded ⚠️

🏷️ Commit: 52b6a09
▶️ Tests: 61634 executed
🟡 Checks: 13/15 completed

Test Failure

SeparateThreadTimeoutInvocation > throws timeout exception when timeout duration is exceeded (:jupiter-tests:test in macOS)
java.lang.AssertionError: 
Expecting code to raise a throwable.
	at org.junit.jupiter.engine.extension.SeparateThreadTimeoutInvocationTests.throwsTimeoutException(SeparateThreadTimeoutInvocationTests.java:50)

@marcphilipp marcphilipp merged commit 7c85124 into junit-team:main Dec 7, 2025
18 checks passed
Ogu1208 pushed a commit to Ogu1208/junit-framework that referenced this pull request Dec 11, 2025
Fixes junit-team#5155.

---------

Signed-off-by: raccoonback <[email protected]>
Co-authored-by: M.P. Korstanje <[email protected]>
Co-authored-by: Marc Philipp <[email protected]>
Signed-off-by: Ogu1208 <[email protected]>
uglide added a commit to uglide/junit-framework that referenced this pull request Dec 22, 2025
)

Fixes junit-team#5155.

---------

Co-authored-by: raccoonback <[email protected]>
Co-authored-by: M.P. Korstanje <[email protected]>
Co-authored-by: Marc Philipp <[email protected]>
uglide added a commit to uglide/junit-framework that referenced this pull request Dec 22, 2025
)

Fixes junit-team#5155.

---------

Co-authored-by: raccoonback <[email protected]>
Co-authored-by: M.P. Korstanje <[email protected]>
Co-authored-by: Marc Philipp <[email protected]>
Signed-off-by: Igor Malinovskiy <[email protected]>
@marcphilipp marcphilipp removed this from the 6.0.2 milestone Dec 28, 2025
marcphilipp added a commit that referenced this pull request Dec 28, 2025
Fixes #5155.

---------

Signed-off-by: raccoonback <[email protected]>
Co-authored-by: M.P. Korstanje <[email protected]>
Co-authored-by: Marc Philipp <[email protected]>
(cherry picked from commit 7c85124)
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

3 participants