This can be done in two ways with the help of the plugin code of this repo. One of the ways is to parallelizing features and other being parallelizing scenarios. The task, which can be used for this purpose is,
CucumberJUnitTestRunner
This task is responsible for preparing necessary infrastructure which will be used by gradle's test task to parallelize the execution.
The consumer should have a test task which should depend on the task,
junitTestRunner
which is available in the plugin and which is of type,CucumberJUnitTestRunner
or have a task of typeCucumberJUnitTestRunner
in your gradle, which should in turn be a dependent task of the test task.
input for this task is given through an extension closure which will be an input for the other task in the plugin of type,
CucumberTask
or the task,cucumberTask
. Properties ofcucumberExtensions
closure are as follows.
stepDefinitionsPath 'com.example.stepdefs' featuresPath 'src/test/resources/com/example' tags '@WIP' parallelize ParallelizeOptions.PARALLELIZE_OPTIONS.SCENARIOS browser 'chrome'
apply plugin: 'supercucumber'
import com.cucumbergoodies.selenium.plugin.ParallelizeOptions
import com.cucumbergoodies.selenium.plugin.tasks.CucumberJUnitTestRunner
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.cucumbergoodies.seleium:cucumber-extensions:1.0'
}
}
task supercucumber(type: CucumberJUnitTestRunner) {
cucumberExtensions {
stepDefinitionsPath 'com.example.stepdefs'
featuresPath 'src/test/resources/com/example'
tags tagsProp
parallelize ParallelizeOptions.PARALLELIZE_OPTIONS.SCENARIOS
browser 'chrome'
}
}
test.dependsOn supercucumber
test.followedBy mergeReports
test {
maxParallelForks = Integer.parseInt(String.valueOf(System.properties.get('maxParallelForks')))
forkEvery = 1
}
The task,
mergeReports
combines all the json files generated by the cucumber runtime. This also combines all the junit xmls generated during the execution. Hence this should be last action after all the tests are run. One of stages where you could call this as a finalizer of test task. If you have any utility that generates a report out of these json files, you should call,mergeReports
before calling that task.