Reputation: 1
I am using cucumber project to execute test scenarios. Now want to execute parallelly using Junit5. project details
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.2</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>1.10.2</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>7.18.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.18.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.11.0</version>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
With runner file
import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.IncludeTags;
import org.junit.platform.suite.api.SelectClasspathResource;
import org.junit.platform.suite.api.Suite;
import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME;
import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME;
import static io.cucumber.junit.platform.engine.Constants.FILTER_TAGS_PROPERTY_NAME;
@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("Features")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "StepDef")
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty")
public class RunJunit5Test {
}
I also added junit-platform.porperties file in src/test/resources with configraution
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.config.strategy = fixed
junit.jupiter.execution.parallel.config.fixed.parallelism = 4
I tried with different integration with surefire plugin but it did not work. It always runs only one scenario in the feature file at a time.
Can anyone help me to execute the tests in parallel using JUnit5?
Upvotes: 0
Views: 329
Reputation: 29
Use junit-platform.propertie
s file and add below config parameter into it
cucumber.execution.parallel.enabled=true
Upvotes: 0
Reputation: 12059
Unlike previous versions of JUnit, JUnit 5 is composed of several different modules from three different sub-projects.
JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage
JUnit Jupiter and JUnit Vintage are test engines that run on the JUnit Platform. JUnit Vintage for JUnit 4, and Jupiter for JUnit 5. Like Vintage and Jupiter, Cucumber is another test engine that runs on the JUnit Platform.
Currently you are configuring junit.jupiter.*
properties for the JUnit Jupiter Engine. These don't do anything for Cucumber. Cucumber uses cucumber.*
properties.
Your POM file looks a bit messy, so probably the best thing to do would be to throw away what you have and start from scratch, using cucumber-java-skeleton as a base. Once you have the scenarios in the skeleton executing correctly, read the documentation for the cucumber-junit-platform-engine
from top to bottom and implement parallel execution.
Upvotes: 0