
The parameter forkCount defines the maximum number of JVM processes that maven-surefire-plugin will spawn concurrently to execute the tests. It supports the same syntax as -T in maven-core: if you terminate the value with a 'C', that value will be multiplied with the number of available CPU cores in your system.
What is forkcount in Maven-surefire?
The parameter forkCount defines the maximum number of JVM processes that maven-surefire-plugin will spawn concurrently to execute the tests. It supports the same syntax as -T in maven-core: if you terminate the value with a 'C', that value will be multiplied with the number of available CPU cores in your system.
What is the default Fork count in Maven surefire plugin?
The default setting is forkCount=1 / reuseForks=true, which means that maven-surefire-plugin creates one new JVM process to execute all tests in one Maven module. forkCount=1 / reuseForks=false executes each test class in its own JVM process, one after another.
What is forkcount=1/reuseforks=true?
The default setting is forkCount=1/reuseForks=true, which means that maven-surefire-plugin creates one new JVM process to execute all tests in one Maven module. forkCount=1/reuseForks=false executes each test class in its own JVM process, one after another.
What is-T in Maven core?
Maven core allows building modules of multi-module projects in parallel with the command line option -T. This multiplies the extent of concurrency configured directly in maven-surefire-plugin. The parameter forkCount defines the maximum number of JVM processes that maven-surefire-plugin will spawn concurrently to execute the tests.

What is fork count in Surefire?
The parameter forkCount defines the maximum number of JVM processes that Surefire will spawn concurrently to execute the tests. It supports the same syntax as -T in maven-core: if you terminate the value with a C, that value will be multiplied with the number of available CPU cores in your system. For example forkCount=2.5C on a Quad-Core system will result in forking up to ten concurrent JVM processes that execute tests.
Can you omit fork related parameters?
Also you can omit fork-related parameters if your tests do NOT affect JVM runtime (usually it's not the case).
What is fork count in Surefire?
The parameter forkCount defines the maximum number of JVM processes that Surefire will spawn concurrently to execute the tests. It supports the same syntax as -T in maven-core: if you terminate the value with a ‘C’, that value will be multiplied with the number of available CPU cores in your system. For example forkCount=2.5C on a Quad-Core system will result in forking up to ten concurrent JVM processes that execute tests.
Can you use parallel with reuseforks?
As reuseForks =false creates a new JVM process for each test class, using parallel = classes would have no effect. You can still use parallel = methods, though.

How Can You Configure The Test Execution ?
- One can impose thread-count limitations on suites, classes or methods using one or more of the parameters threadCountSuites, threadCountClasses and threadCountMethods. If only threadCount is specified, Surefire attempts to estimate the thread counts for suites, classes and methods and reuses the threads in favor of a leaf, e.g. parallel methods (possibly increasing con…
Parallel Test Execution and Single Thread Execution
- As mentioned above the parallel test execution is used with specific thread count. Since of Surefire 2.18, you can apply the JCIP annotation @net.jcip.annotations.NotThreadSafe on the Java class of JUnit test (test class, Suite, Parameterized, etc.) in order to execute it in single Thread instance. The Thread has name “maven-surefire-plugin@NotThreadSafe“. This way the p…
Forked Test Execution
- The parameter reuseForks: to reuse the processes to execute the next tests (reuseForks=true/false). The default setting is forkCount=1/reuseForks=true, which means that Surefire creates one new JVM process to execute all tests in one maven module. forkCount=1/reuseForks=false executes each test class in its own JVM process, one a…
Examples
- In your pom.xml file: Add ths surefire plugin. After, you must set the parallel parameter, and may change thethreadCount or useUnlimitedThreadsattribute. As of Surefire 2.7, no additional dependencies are needed to use the full set of options with parallel. As of Surefire 2.16, new thread-count attributes are introduced, namely threadCountSuites, threadCountClasses and thre…