From 2a19d84cba6ae26e16dd90e0bb130b7318fd87a9 Mon Sep 17 00:00:00 2001 From: David Waltermire Date: Sat, 4 Jan 2025 00:09:47 -0500 Subject: [PATCH] Add support for parallel JUnit execution to speed up builds. --- .../cli/processor/ExitCodeTest.java | 3 ++ .../nist/secauto/metaschema/cli/CLITest.java | 3 ++ .../EvaluateMetapathSubCommandTest.java | 3 ++ pom.xml | 31 ++++++++++++++++--- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/cli-processor/src/test/java/gov/nist/secauto/metaschema/cli/processor/ExitCodeTest.java b/cli-processor/src/test/java/gov/nist/secauto/metaschema/cli/processor/ExitCodeTest.java index 988e7f93b..7f9d63da8 100644 --- a/cli-processor/src/test/java/gov/nist/secauto/metaschema/cli/processor/ExitCodeTest.java +++ b/cli-processor/src/test/java/gov/nist/secauto/metaschema/cli/processor/ExitCodeTest.java @@ -15,6 +15,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; import java.util.LinkedList; import java.util.List; @@ -25,6 +27,7 @@ * Logging solution based on * https://stackoverflow.com/questions/24205093/how-to-create-a-custom-appender-in-log4j2. */ +@Execution(value = ExecutionMode.SAME_THREAD, reason = "Log capturing needs to be single threaded") class ExitCodeTest { private static MockedAppender mockedAppender; private static Logger logger; diff --git a/metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/CLITest.java b/metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/CLITest.java index c4d70aca3..4bbe3a49d 100644 --- a/metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/CLITest.java +++ b/metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/CLITest.java @@ -14,6 +14,8 @@ import gov.nist.secauto.metaschema.cli.processor.ExitStatus; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -28,6 +30,7 @@ /** * Unit test for simple CLI. */ +@Execution(value = ExecutionMode.SAME_THREAD, reason = "Log capturing needs to be single threaded") public class CLITest { private static final ExitCode NO_EXCEPTION_CLASS = null; diff --git a/metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathSubCommandTest.java b/metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathSubCommandTest.java index 9949e77fd..06c5a2222 100644 --- a/metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathSubCommandTest.java +++ b/metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathSubCommandTest.java @@ -10,9 +10,12 @@ import gov.nist.secauto.metaschema.cli.CLI; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; import nl.altindag.log.LogCaptor; +@Execution(value = ExecutionMode.SAME_THREAD, reason = "Log capturing needs to be single threaded") class EvaluateMetapathSubCommandTest { @Test diff --git a/pom.xml b/pom.xml index cb971dd31..db64324e5 100644 --- a/pom.xml +++ b/pom.xml @@ -690,16 +690,39 @@ org.apache.maven.plugins maven-surefire-plugin + + + me.fabriciorby + maven-surefire-junit5-tree-reporter + 1.4.0 + + - 1.5C - true JAVA_TOOL_OPTIONS - - false true + + 1.5C + true + + + + + + junit.jupiter.execution.parallel.enabled = true + junit.jupiter.execution.parallel.mode.default = concurrent + + + + plain + + true + + +