Skip to main content

Cucumber Parallel Execution JUnit

Cucumber can be executed in parallel using JUnit and Maven test execution plugins. You can use either Maven Surefire or Failsafe plugin to execute the runners.

Parallel Execution in Cucumber using Maven Surefire Plugin

Step 1: Add Maven Surefire plugin

Add below code in plugins section of pom.xml. Replace the latest version from here

  • threadCount: The thread count in the above setting is 3 threads per core.
  • perCoreThreadCount: If you want this to be 3 threads across all cores set the perCoreThreadCount to false.
  • useUnlimitedThreads: To set the thread count to useUnlimitedThreads instead of specific number set useUnlimitedThreads to true. 
  • parallel: In case of multiple runners one can also set the parallel option to classesAndMethods or classes in addition to methods.

Step 2: Use Maven command to run

Use the Maven test or a suitable command to execute the POM. This should run in parallel threaded mode.

$ mvn test

Note: In JUnit the feature files are run in parallel rather than scenarios, which means all the scenarios in a feature file will be executed by the same thread.

Video Tutorial: Parallel Testing in Cucumber

Submitted by tgoswami on August 31, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.