Reputation: 353
I'm using Cucumber with Gradle and would like to run Cucumber features in parallel but can't figure out how. My cucumber executor looks like this:
task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "cucumber.api.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'pretty',
'--plugin', 'json:build/reports/cucumber-report.json',
'--plugin', 'html:build/reports/cucumber-report.html',
'--glue', 'stepDefinitions',
'src/test/java']
systemProperty "cucumber.options", System.getProperty("cucumber.options")
}
}
}
Thanks, any help is appreciated
Upvotes: 1
Views: 2856
Reputation: 198
There is a bit of setup needed to get cucumber running in parallel properly with gradle.
For your specific question in the build.gradle you determine the --threads cucumber option.
Take a look in the build.gradle here
These variables are used to setup parallel runs and determine threads to use in the cucumber options
def availableThreadCount = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
def cucumberThreadsOption = ['--threads', availableThreadCount.toString()]
if runInParallel task is used it puts setParallel to true. We then add the --threads arg into the cucumber options This is where that happens in the cucumber task
Here is where the built cucumber options are used
CreateSharedDrivers.java here is where we handle creating multiple drivers for threads and have the shutdown hook implemented.
In Hooks.java here there is an example of how we log the thread and its current scenario
Upvotes: 2