Steps to reproduce
- Set up parallel test execution, for example, with 4 fixed threads
- Write a test class with multiple test methods, apply
@ResourceLock annotation to one of the methods
- Declare this class a template and make a couple of invocations for it
- Run the test class. Code example is provided below
junit.jupiter.execution.parallel.enabled=true
junit.jupiter.execution.parallel.mode.default=concurrent
junit.jupiter.execution.parallel.config.strategy=fixed
junit.jupiter.execution.parallel.config.fixed.parallelism=4
@ClassTemplate
@ExtendWith(MethodResourceLockClassTemplateExtension.class)
public class MethodResourceLockClassTemplateTest {
@Test
void test1() throws InterruptedException {
Thread.sleep(2000);
}
@Test
void test2() throws InterruptedException {
Thread.sleep(2000);
}
@Test
@ResourceLock("1")
void test3() throws InterruptedException {
Thread.sleep(2000);
}
}
@NullMarked
public class MethodResourceLockClassTemplateExtension implements ClassTemplateInvocationContextProvider {
@Override
public boolean supportsClassTemplate(ExtensionContext context) {
return true;
}
@Override
public Stream<? extends ClassTemplateInvocationContext> provideClassTemplateInvocationContexts(ExtensionContext context) {
return Stream.of(new ClassTemplateInvocationContext() {}, new ClassTemplateInvocationContext() {});
}
}
Expected result
All tests are being run in parallel, the annotated test method respects the resource lock
Actual result
All tests are being run sequentially
Context
- Used versions (Jupiter/Vintage/Platform): 6.0.0
- Build Tool/IDE: IntelliJ IDEA 2025.2.2
Steps to reproduce
@ResourceLockannotation to one of the methodsExpected result
All tests are being run in parallel, the annotated test method respects the resource lock
Actual result
All tests are being run sequentially
Context