In modern testing environments, parallel test execution can significantly improve the efficiency and speed of testing processes. Cucumber, a popular behavior-driven development (BDD) framework, allows for parallel execution of feature files.
To achieve parallel execution in Cucumber, you can use the cucumber-jvm-parallel-plugin. This plugin dynamically creates test runner classes that can be executed in parallel.
com.github.temyers
cucumber-jvm-parallel-plugin
2.1.0
com.github.temyers
cucumber-jvm-parallel-plugin
2.1.0
generateRunners
generate-test-sources
generateRunners
foo, bar
${project.build.directory}/generated-test-sources/cucumber
src/test/resources/features/
target/cucumber-parallel
json
Add a Maven Surefire plugin to invoke the generated runner classes in parallel:
org.apache.maven.plugins
maven-surefire-plugin
2.19
5
true
**/*IT.class
To execute tests in parallel, the WebDriver instance must be shared and not explicitly closed within the tests. The SharedDriver class achieves this:
public class SharedDriver extends EventFiringWebDriver {
private static WebDriver REAL_DRIVER = null;
static {
Runtime.getRuntime().addShutdownHook(CLOSE_THREAD);
}
public SharedDriver() {
super(CreateDriver());
}
public static WebDriver CreateDriver() {
WebDriver webDriver;
if (REAL_DRIVER == null)
webDriver = new FirefoxDriver();
setWebDriver(webDriver);
return webDriver;
}
}
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3