From 62d4652df3bfd10eee6115147b8082c272502124 Mon Sep 17 00:00:00 2001 From: yongjunhong Date: Sat, 11 Jan 2025 21:29:51 +0900 Subject: [PATCH] Add parameters for parallel execution of classes and methods Issue: #4238 --- .../org/junit/vintage/engine/Constants.java | 22 +++++++++++++++++++ .../vintage/engine/VintageTestEngine.java | 8 +++++++ 2 files changed, 30 insertions(+) diff --git a/junit-vintage-engine/src/main/java/org/junit/vintage/engine/Constants.java b/junit-vintage-engine/src/main/java/org/junit/vintage/engine/Constants.java index abb85e3eb61d..803db1e5f051 100644 --- a/junit-vintage-engine/src/main/java/org/junit/vintage/engine/Constants.java +++ b/junit-vintage-engine/src/main/java/org/junit/vintage/engine/Constants.java @@ -46,6 +46,28 @@ public final class Constants { @API(status = EXPERIMENTAL, since = "5.12") public static final String PARALLEL_POOL_SIZE = "junit.vintage.execution.parallel.pool-size"; + /** + * Indicates whether parallel execution is enabled for test classes in the JUnit Vintage engine. + * + *

Set this property to {@code true} to enable parallel execution of test classes. + * Defaults to {@code false}. + * + * @since 5.13 + */ + @API(status = EXPERIMENTAL, since = "5.13") + public static final String PARALLEL_CLASS_EXECUTION = "junit.vintage.execution.parallel.classes"; + + /** + * Indicates whether parallel execution is enabled for test methods in the JUnit Vintage engine. + * + *

Set this property to {@code true} to enable parallel execution of test methods. + * Defaults to {@code false}. + * + * @since 5.13 + */ + @API(status = EXPERIMENTAL, since = "5.13") + public static final String PARALLEL_METHOD_EXECUTION = "junit.vintage.execution.parallel.methods"; + private Constants() { /* no-op */ } diff --git a/junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java b/junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java index 3d6840592891..9cec4c20fb9d 100644 --- a/junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java +++ b/junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java @@ -165,6 +165,14 @@ private boolean getParallelExecutionEnabled(ExecutionRequest request) { return request.getConfigurationParameters().getBoolean(PARALLEL_EXECUTION_ENABLED).orElse(false); } + private boolean getParallelClassExecutionEnabled(ExecutionRequest request) { + return request.getConfigurationParameters().getBoolean(Constants.PARALLEL_CLASS_EXECUTION).orElse(false); + } + + private boolean getParallelMethodExecutionEnabled(ExecutionRequest request) { + return request.getConfigurationParameters().getBoolean(Constants.PARALLEL_METHOD_EXECUTION).orElse(false); + } + private int getThreadPoolSize(ExecutionRequest request) { Optional poolSize = request.getConfigurationParameters().get(PARALLEL_POOL_SIZE); if (poolSize.isPresent()) {