Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suport junit parallel execution #337

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 27 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -690,16 +690,39 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>me.fabriciorby</groupId>
<artifactId>maven-surefire-junit5-tree-reporter</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
<configuration>
<forkCount>1.5C</forkCount>
<reuseForks>true</reuseForks>
<excludedEnvironmentVariables>
<excludedEnvironmentVariable>JAVA_TOOL_OPTIONS</excludedEnvironmentVariable>
</excludedEnvironmentVariables>
<!-- Use of TCP to transmit events to the plugin -->
<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory" />
<useModulePath>false</useModulePath>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<!-- fork configuration -->
<forkCount>1.5C</forkCount>
<reuseForks>true</reuseForks>
<!-- Use of TCP to transmit events to the plugin -->
<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory" />
<!-- Junit5 parallel configuration -->
<properties>
<configurationParameters>
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
</configurationParameters>
</properties>
<!-- tree reporter configuration -->
<reportFormat>plain</reportFormat>
<consoleOutputReporter>
<disable>true</disable>
</consoleOutputReporter>
<statelessTestsetInfoReporter
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
</statelessTestsetInfoReporter>
</configuration>
</plugin>
<plugin>
Expand Down
Loading