Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.saulius:gradle-cucumber-jvm-plugin:'
}
dependencies {
implementation("com.github.saulius:gradle-cucumber-jvm-plugin:")
}
<dependency>
<groupId>com.github.saulius</groupId>
<artifactId>gradle-cucumber-jvm-plugin</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.saulius" % "gradle-cucumber-jvm-plugin" % ""
:dependencies [[com.github.saulius/gradle-cucumber-jvm-plugin ""]]
The gradle cucumber-jvm plugin provides the ability to run cucumber acceptance tests directly from a gradle build. The plugin utilizes the cucumber cli provided by the cucumber-jvm project, while imposing a few constraints to encourage adopters to use cucumber in a gradle friendly manner. Some of constraints include:
The inspiration for this plugin drew heavily from the work of Samuel Brown's Cucumber Plugin and Camilo Ribeiro's Cucumber Gradle Parallel Example.
The following gradle configuration will create a new Cucumber based test suite named cucumberTest and configure it to run up to 3 parallel forks. The cucumberTest source set will depend on the project's main source set.
buildscript {
repositories {
maven {
url "http://repo.bodar.com"
}
jcenter()
}
dependencies {
classpath 'com.commercehub:gradle-cucumber-jvm-plugin:0.6'
}
}
apply plugin: 'java'
apply plugin: 'cucumber-jvm'
addCucumberSuite 'cucumberTest'
cucumber {
maxParallelForks = 3
}
cucumberTest {
stepDefinitionRoots = ['cucumber.steps', 'cucumber.hooks']
}
repositories {
jcenter()
}
dependencies {
cucumberTestCompile 'info.cukes:cucumber-java:1.2.2'
}
Running the following command will execute the test suite:
gradle(w) cucumberTest
Cucumber tasks can be configured at two levels, globally for the project and individually for a test suite. This allows for projects to contain multiple Cucumber test suites that can differ on some properties while inheriting other property values form the project defaults. Both levels of configuration make the following settings available:
stepDefinitionRoots
: A list of root packages to scan the classpath for glue code. Default to ['cucumber.steps', 'cucumber.hooks']featureRoots
: A list of root packages to scan the resources folders on the classpath for feature files. Defaults to ['features']tags
: A list of tags to identify scenarios to run. Default to an empty list.isStrict
: A boolean value indicating whether scenarios should be evaluated strictly. Defaults to falsesnippits
: Indicator to cucumber on what style to use for generated step examples. Legal values include camelcase, underscore. Defaults to camelcasemaxParallelForks
: Maximum number of forked Java processes to start to run tests in parallel. Default to 1By default, this plugin will generate reports based on masterthought's Cucumber reporting project.
Junit reporting can be enabled by setting the junitReport
property to true.