Parallel support was introduced in cucumber-jvm:4.0.0
. So your dependencies are ok.
If you are using Maven:
Cucumber JUnit - Parallel Execution with Maven
Cucumber JUnit supports parallel execution of feature files across multiple threads. To enable this with maven set the parallel property to either methods
or both
.
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<parallel>both</parallel>
<threadCount>4</threadCount>
</configuration>
</plugin>
</plugins>
</build>
If you are using Gralde you are better off using the Gradle Cucumber Plugin as Gradle doesn't support sub-class level parallelization. In this case you don't need cucumber-junit
.
Gradle Cucumber runner - Running features in parallel
Cucumber supports parallel execution if you specify the number of
thread to use. This can be done in two ways
- An option whn running from a command line,
./gradlew cucumber --threads 4
, this will run four parallel threads
- An extension, that is setting the value in your
build.gradle
file in the cucumber section.
When setting the value in the build script, you can't really know how
many threads the build will have access to. Hardcoding a fixed number
may not be your best option.
One way of specifying the number of threads to use is:
cucumber {
threads = = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
}
This will use as many threads as possible while leaving resources for
Gradle to execute.