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

Fixes junit-team#5155

Signed-off-by: raccoonback <kosb15@naver.com>
@raccoonback
Copy link
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
Signed-off-by: raccoonback <kosb15@naver.com>
@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
Contributor Author

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

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

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
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