|
17 | 17 | import static org.junit.jupiter.api.Order.DEFAULT; |
18 | 18 | import static org.junit.jupiter.engine.Constants.DEFAULT_PARALLEL_EXECUTION_MODE; |
19 | 19 | import static org.junit.jupiter.engine.Constants.DEFAULT_TEST_METHOD_ORDER_PROPERTY_NAME; |
| 20 | +import static org.junit.jupiter.engine.Constants.PARALLEL_CONFIG_EXECUTOR_SERVICE_PROPERTY_NAME; |
20 | 21 | import static org.junit.jupiter.engine.Constants.PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME; |
21 | 22 | import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass; |
22 | 23 | import static org.junit.platform.launcher.LauncherConstants.CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME; |
|
34 | 35 | import java.util.logging.LogRecord; |
35 | 36 | import java.util.regex.Pattern; |
36 | 37 |
|
| 38 | +import org.jspecify.annotations.NullMarked; |
37 | 39 | import org.jspecify.annotations.Nullable; |
38 | 40 | import org.junit.jupiter.api.BeforeEach; |
39 | 41 | import org.junit.jupiter.api.DisplayName; |
|
57 | 59 | import org.junit.jupiter.api.parallel.Execution; |
58 | 60 | import org.junit.jupiter.api.parallel.ExecutionMode; |
59 | 61 | import org.junit.jupiter.engine.JupiterTestEngine; |
| 62 | +import org.junit.jupiter.params.ParameterizedClass; |
60 | 63 | import org.junit.jupiter.params.ParameterizedTest; |
| 64 | +import org.junit.jupiter.params.provider.EnumSource; |
61 | 65 | import org.junit.jupiter.params.provider.ValueSource; |
62 | 66 | import org.junit.platform.commons.logging.LogRecordListener; |
63 | 67 | import org.junit.platform.commons.util.ClassUtils; |
64 | 68 | import org.junit.platform.engine.DiscoveryIssue; |
65 | 69 | import org.junit.platform.engine.DiscoveryIssue.Severity; |
66 | 70 | import org.junit.platform.engine.support.descriptor.ClassSource; |
67 | 71 | import org.junit.platform.engine.support.descriptor.MethodSource; |
| 72 | +import org.junit.platform.engine.support.hierarchical.ConcurrentHierarchicalTestExecutorServiceFactory.ConcurrentExecutorServiceType; |
68 | 73 | import org.junit.platform.testkit.engine.EngineDiscoveryResults; |
69 | 74 | import org.junit.platform.testkit.engine.EngineTestKit; |
70 | 75 | import org.junit.platform.testkit.engine.Events; |
|
76 | 81 | * |
77 | 82 | * @since 5.4 |
78 | 83 | */ |
79 | | -class OrderedMethodTests { |
| 84 | +@ParameterizedClass |
| 85 | +@EnumSource(ConcurrentExecutorServiceType.class) |
| 86 | +record OrderedMethodTests(ConcurrentExecutorServiceType executorServiceType) { |
80 | 87 |
|
81 | 88 | private static final Set<String> callSequence = Collections.synchronizedSet(new LinkedHashSet<>()); |
82 | 89 | private static final Set<String> threadNames = Collections.synchronizedSet(new LinkedHashSet<>()); |
@@ -361,12 +368,13 @@ private Events executeTestsInParallel(Class<?> testClass, @Nullable Class<? exte |
361 | 368 | .testEvents(); |
362 | 369 | } |
363 | 370 |
|
364 | | - private static EngineTestKit.Builder testKit(Class<?> testClass, |
365 | | - @Nullable Class<? extends MethodOrderer> defaultOrderer, Severity criticalSeverity) { |
| 371 | + private EngineTestKit.Builder testKit(Class<?> testClass, @Nullable Class<? extends MethodOrderer> defaultOrderer, |
| 372 | + Severity criticalSeverity) { |
366 | 373 |
|
367 | 374 | var testKit = EngineTestKit.engine("junit-jupiter") // |
368 | 375 | .configurationParameter(PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME, "true") // |
369 | 376 | .configurationParameter(DEFAULT_PARALLEL_EXECUTION_MODE, "concurrent") // |
| 377 | + .configurationParameter(PARALLEL_CONFIG_EXECUTOR_SERVICE_PROPERTY_NAME, executorServiceType.name()) // |
370 | 378 | .configurationParameter(CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME, criticalSeverity.name()); |
371 | 379 | if (defaultOrderer != null) { |
372 | 380 | testKit.configurationParameter(DEFAULT_TEST_METHOD_ORDER_PROPERTY_NAME, defaultOrderer.getName()); |
@@ -767,7 +775,8 @@ public void orderMethods(MethodOrdererContext context) { |
767 | 775 |
|
768 | 776 | @SuppressWarnings("unchecked") |
769 | 777 | static <T> T createMethodDescriptorImpersonator(MethodDescriptor method) { |
770 | | - MethodDescriptor stub = new MethodDescriptor() { |
| 778 | + @NullMarked |
| 779 | + class Stub implements MethodDescriptor { |
771 | 780 | @Override |
772 | 781 | public Method getMethod() { |
773 | 782 | throw new UnsupportedOperationException(); |
@@ -803,8 +812,8 @@ public boolean equals(Object obj) { |
803 | 812 | public int hashCode() { |
804 | 813 | return method.hashCode(); |
805 | 814 | } |
806 | | - }; |
807 | | - return (T) stub; |
| 815 | + } |
| 816 | + return (T) new Stub(); |
808 | 817 | } |
809 | 818 | } |
810 | 819 |
|
|
0 commit comments