-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Open
Copy link
Description
Following the discussion here #5023
Steps to reproduce
- Set up parallel test execution, for example, with 4 fixed threads
- Write a method-ordered test class annotated with
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
and with order being assigned to its test 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
@ExtendWith(MethodOrderedClassTemplateExtension.class)
@ClassTemplate
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class MethodOrderedClassTemplateTest {
@Test
@Order(0)
void test1() throws InterruptedException {
Thread.sleep(2000);
}
@Test
@Order(1)
void test2() throws InterruptedException {
Thread.sleep(2000);
}
}
@NullMarked
public class MethodOrderedClassTemplateExtension 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
Invocations are being run in parallel while test method order is being respected within each invocation
Actual result
Invocations are being run sequentially
Context
- Used versions (Jupiter/Vintage/Platform): 6.0.0
- Build Tool/IDE: IntelliJ IDEA 2025.2.2