Skip to content

Commit 979a1be

Browse files
committed
Run more tests against both implementations
1 parent a392f00 commit 979a1be

File tree

4 files changed

+44
-17
lines changed

4 files changed

+44
-17
lines changed

jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/ExtensionRegistrationViaParametersAndFieldsTests.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,16 @@
7070
import org.junit.jupiter.api.fixtures.TrackLogRecords;
7171
import org.junit.jupiter.api.parallel.Execution;
7272
import org.junit.jupiter.engine.AbstractJupiterTestEngineTests;
73-
import org.junit.jupiter.engine.config.JupiterConfiguration;
73+
import org.junit.jupiter.engine.Constants;
7474
import org.junit.jupiter.engine.execution.injection.sample.LongParameterResolver;
7575
import org.junit.jupiter.params.ParameterizedTest;
76+
import org.junit.jupiter.params.provider.EnumSource;
7677
import org.junit.jupiter.params.provider.ValueSource;
7778
import org.junit.platform.commons.PreconditionViolationException;
7879
import org.junit.platform.commons.logging.LogRecordListener;
7980
import org.junit.platform.commons.support.ModifierSupport;
8081
import org.junit.platform.commons.util.ExceptionUtils;
82+
import org.junit.platform.engine.support.hierarchical.ConcurrentHierarchicalTestExecutorServiceFactory.ConcurrentExecutorServiceType;
8183
import org.junit.platform.testkit.engine.EngineExecutionResults;
8284

8385
/**
@@ -205,11 +207,14 @@ void registersProgrammaticTestInstancePostProcessors() {
205207
assertOneTestSucceeded(ProgrammaticTestInstancePostProcessorTestCase.class);
206208
}
207209

208-
@Test
209-
void createsExtensionPerInstance() {
210+
@ParameterizedTest
211+
@EnumSource(ConcurrentExecutorServiceType.class)
212+
void createsExtensionPerInstance(ConcurrentExecutorServiceType executorServiceType) {
210213
var results = executeTests(request() //
211214
.selectors(selectClass(InitializationPerInstanceTestCase.class)) //
212-
.configurationParameter(JupiterConfiguration.PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME, "true") //
215+
.configurationParameter(Constants.PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME, "true") //
216+
.configurationParameter(Constants.PARALLEL_CONFIG_EXECUTOR_SERVICE_PROPERTY_NAME,
217+
executorServiceType.name()) //
213218
);
214219
assertTestsSucceeded(results, 100);
215220
}

jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/OrderedMethodTests.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import static org.junit.jupiter.api.Order.DEFAULT;
1818
import static org.junit.jupiter.engine.Constants.DEFAULT_PARALLEL_EXECUTION_MODE;
1919
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;
2021
import static org.junit.jupiter.engine.Constants.PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME;
2122
import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass;
2223
import static org.junit.platform.launcher.LauncherConstants.CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME;
@@ -34,6 +35,7 @@
3435
import java.util.logging.LogRecord;
3536
import java.util.regex.Pattern;
3637

38+
import org.jspecify.annotations.NullMarked;
3739
import org.jspecify.annotations.Nullable;
3840
import org.junit.jupiter.api.BeforeEach;
3941
import org.junit.jupiter.api.DisplayName;
@@ -57,14 +59,17 @@
5759
import org.junit.jupiter.api.parallel.Execution;
5860
import org.junit.jupiter.api.parallel.ExecutionMode;
5961
import org.junit.jupiter.engine.JupiterTestEngine;
62+
import org.junit.jupiter.params.ParameterizedClass;
6063
import org.junit.jupiter.params.ParameterizedTest;
64+
import org.junit.jupiter.params.provider.EnumSource;
6165
import org.junit.jupiter.params.provider.ValueSource;
6266
import org.junit.platform.commons.logging.LogRecordListener;
6367
import org.junit.platform.commons.util.ClassUtils;
6468
import org.junit.platform.engine.DiscoveryIssue;
6569
import org.junit.platform.engine.DiscoveryIssue.Severity;
6670
import org.junit.platform.engine.support.descriptor.ClassSource;
6771
import org.junit.platform.engine.support.descriptor.MethodSource;
72+
import org.junit.platform.engine.support.hierarchical.ConcurrentHierarchicalTestExecutorServiceFactory.ConcurrentExecutorServiceType;
6873
import org.junit.platform.testkit.engine.EngineDiscoveryResults;
6974
import org.junit.platform.testkit.engine.EngineTestKit;
7075
import org.junit.platform.testkit.engine.Events;
@@ -76,7 +81,9 @@
7681
*
7782
* @since 5.4
7883
*/
79-
class OrderedMethodTests {
84+
@ParameterizedClass
85+
@EnumSource(ConcurrentExecutorServiceType.class)
86+
record OrderedMethodTests(ConcurrentExecutorServiceType executorServiceType) {
8087

8188
private static final Set<String> callSequence = Collections.synchronizedSet(new LinkedHashSet<>());
8289
private static final Set<String> threadNames = Collections.synchronizedSet(new LinkedHashSet<>());
@@ -361,12 +368,13 @@ private Events executeTestsInParallel(Class<?> testClass, @Nullable Class<? exte
361368
.testEvents();
362369
}
363370

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) {
366373

367374
var testKit = EngineTestKit.engine("junit-jupiter") //
368375
.configurationParameter(PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME, "true") //
369376
.configurationParameter(DEFAULT_PARALLEL_EXECUTION_MODE, "concurrent") //
377+
.configurationParameter(PARALLEL_CONFIG_EXECUTOR_SERVICE_PROPERTY_NAME, executorServiceType.name()) //
370378
.configurationParameter(CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME, criticalSeverity.name());
371379
if (defaultOrderer != null) {
372380
testKit.configurationParameter(DEFAULT_TEST_METHOD_ORDER_PROPERTY_NAME, defaultOrderer.getName());
@@ -767,7 +775,8 @@ public void orderMethods(MethodOrdererContext context) {
767775

768776
@SuppressWarnings("unchecked")
769777
static <T> T createMethodDescriptorImpersonator(MethodDescriptor method) {
770-
MethodDescriptor stub = new MethodDescriptor() {
778+
@NullMarked
779+
class Stub implements MethodDescriptor {
771780
@Override
772781
public Method getMethod() {
773782
throw new UnsupportedOperationException();
@@ -803,8 +812,8 @@ public boolean equals(Object obj) {
803812
public int hashCode() {
804813
return method.hashCode();
805814
}
806-
};
807-
return (T) stub;
815+
}
816+
return (T) new Stub();
808817
}
809818
}
810819

jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/RepeatedTestTests.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import static org.junit.jupiter.api.Assertions.assertNotNull;
1616
import static org.junit.jupiter.api.Assertions.fail;
1717
import static org.junit.jupiter.engine.Constants.DEFAULT_PARALLEL_EXECUTION_MODE;
18+
import static org.junit.jupiter.engine.Constants.PARALLEL_CONFIG_EXECUTOR_SERVICE_PROPERTY_NAME;
1819
import static org.junit.jupiter.engine.Constants.PARALLEL_CONFIG_FIXED_PARALLELISM_PROPERTY_NAME;
1920
import static org.junit.jupiter.engine.Constants.PARALLEL_CONFIG_STRATEGY_PROPERTY_NAME;
2021
import static org.junit.jupiter.engine.Constants.PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME;
@@ -46,8 +47,11 @@
4647
import org.junit.jupiter.api.Test;
4748
import org.junit.jupiter.api.TestInfo;
4849
import org.junit.jupiter.engine.AbstractJupiterTestEngineTests;
50+
import org.junit.jupiter.params.ParameterizedTest;
51+
import org.junit.jupiter.params.provider.EnumSource;
4952
import org.junit.platform.commons.support.ReflectionSupport;
5053
import org.junit.platform.engine.DiscoveryIssue.Severity;
54+
import org.junit.platform.engine.support.hierarchical.ConcurrentHierarchicalTestExecutorServiceFactory.ConcurrentExecutorServiceType;
5155
import org.junit.platform.launcher.LauncherDiscoveryRequest;
5256
import org.junit.platform.testkit.engine.Events;
5357

@@ -135,7 +139,7 @@ static void afterAll() {
135139
@BeforeEach
136140
@AfterEach
137141
void beforeAndAfterEach(TestInfo testInfo, RepetitionInfo repetitionInfo) {
138-
switch (testInfo.getTestMethod().get().getName()) {
142+
switch (testInfo.getTestMethod().orElseThrow().getName()) {
139143
case "repeatedOnce" -> {
140144
assertThat(repetitionInfo.getCurrentRepetition()).isEqualTo(1);
141145
assertThat(repetitionInfo.getTotalRepetitions()).isEqualTo(1);
@@ -291,14 +295,16 @@ void failureThreshold3() {
291295
// @formatter:on
292296
}
293297

294-
@Test
295-
void failureThresholdWithConcurrentExecution() {
298+
@ParameterizedTest
299+
@EnumSource(ConcurrentExecutorServiceType.class)
300+
void failureThresholdWithConcurrentExecution(ConcurrentExecutorServiceType executorServiceType) {
296301
Class<TestCase> testClass = TestCase.class;
297302
String methodName = "failureThresholdWithConcurrentExecution";
298-
Method method = ReflectionSupport.findMethod(testClass, methodName).get();
303+
Method method = ReflectionSupport.findMethod(testClass, methodName).orElseThrow();
299304
LauncherDiscoveryRequest request = request()//
300305
.selectors(selectMethod(testClass, method))//
301306
.configurationParameter(PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME, "true")//
307+
.configurationParameter(PARALLEL_CONFIG_EXECUTOR_SERVICE_PROPERTY_NAME, executorServiceType.name()) //
302308
.configurationParameter(DEFAULT_PARALLEL_EXECUTION_MODE, "concurrent")//
303309
.configurationParameter(PARALLEL_CONFIG_STRATEGY_PROPERTY_NAME, "fixed")//
304310
.configurationParameter(PARALLEL_CONFIG_FIXED_PARALLELISM_PROPERTY_NAME, "4")//
@@ -323,7 +329,7 @@ void failureThresholdWithConcurrentExecution() {
323329

324330
private Events executeTest(String methodName) {
325331
Class<TestCase> testClass = TestCase.class;
326-
Method method = ReflectionSupport.findMethod(testClass, methodName).get();
332+
Method method = ReflectionSupport.findMethod(testClass, methodName).orElseThrow();
327333
return executeTests(selectMethod(testClass, method)).allEvents();
328334
}
329335

platform-tests/src/test/java/org/junit/platform/engine/support/hierarchical/ForkJoinDeadLockTests.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@
3232
import org.junit.jupiter.api.parallel.Isolated;
3333
import org.junit.jupiter.api.parallel.ResourceLock;
3434
import org.junit.jupiter.engine.Constants;
35+
import org.junit.jupiter.params.ParameterizedClass;
36+
import org.junit.jupiter.params.provider.EnumSource;
37+
import org.junit.platform.engine.support.hierarchical.ConcurrentHierarchicalTestExecutorServiceFactory.ConcurrentExecutorServiceType;
3538
import org.junit.platform.testkit.engine.EngineTestKit;
3639

3740
// https://github.com/junit-team/junit-framework/issues/3945
3841
@Timeout(10)
39-
public class ForkJoinDeadLockTests {
42+
@ParameterizedClass
43+
@EnumSource(ConcurrentExecutorServiceType.class)
44+
record ForkJoinDeadLockTests(ConcurrentExecutorServiceType executorServiceType) {
4045

4146
@Test
4247
void forkJoinExecutionDoesNotLeadToDeadLock() {
@@ -53,10 +58,12 @@ void multiLevelLocks() {
5358
run(ClassLevelTestCase.class);
5459
}
5560

56-
private static void run(Class<?>... classes) {
61+
private void run(Class<?>... classes) {
5762
EngineTestKit.engine("junit-jupiter") //
5863
.selectors(selectClasses(classes)) //
5964
.configurationParameter(Constants.PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME, "true") //
65+
.configurationParameter(Constants.PARALLEL_CONFIG_EXECUTOR_SERVICE_PROPERTY_NAME,
66+
executorServiceType.name()) //
6067
.configurationParameter(Constants.DEFAULT_PARALLEL_EXECUTION_MODE, "concurrent") //
6168
.configurationParameter(Constants.DEFAULT_CLASSES_EXECUTION_MODE_PROPERTY_NAME, "concurrent") //
6269
.configurationParameter(Constants.PARALLEL_CONFIG_STRATEGY_PROPERTY_NAME, "fixed") //

0 commit comments

Comments
 (0)