![Cucumber Logo] (http://cukes.info/images/cuke_logo.png)
The gradle cucumber 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 and should support any of the languages utilized in cucumber-jvm.
(Currently only tested with Java, Groovy, and JRuby more coming soon!)
- [Samuel Brown] (https://github.com/samueltbrown)
- [Matthew Lucas] (https://github.com/lucas1000001)
- [Philippe Vosges] (https://github.com/viphe)
- [Paul Bellchambers] (https://github.com/pbellchambers)
- [Simon Wiehe] (https://github.com/klunk)
You can apply the plugin using the following buildscript
:
apply plugin: 'cucumber'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.samueltbrown:gradle-cucumber-plugin:0.6'
}
}
Older versions can be downloaded directly from GitHub like so;
buildscript {
apply from: 'https://github.com/samueltbrown/gradle-cucumber-plugin/raw/master/repo/gradle-cucumber-plugin/gradle-cucumber-plugin/0.3/cucumberinit.gradle'
}
Once the plugin has been applied, the project dependencies need to be updated with the cucumber-jvm jar file needed for your language. Below 'groovy' is the chosen language.
dependencies {
...
cucumberRuntime 'info.cukes:cucumber-groovy:1.1.5'
}
If you have a src/cucumber
source set (similar to src/test
), the plugin will automatically detect it and
setup Java tasks and configurations for you. The "cucumber" code unit depends on "test", the same way "test" depends on
"main". Also, choose your library dependencies:
dependencies {
cucumberCompile 'info.cukes:cucumber-groovy:1.1.5'
}
Write your feature files under src/cucumber/resources
.
Currently the plugin only supports one task to run your cucumber tests:
>gradle cucumber
The cucumber task has several configurable properties:
formats
: A list of output formats. (Defaults to pretty)glueDirs
: A list of directories where stepdefs and supporting code are located (Defaults to src/test/java)featureDirs
: A list of directories where feature files are located.(Defaults to src/test/resources)tags
: only scenarios having these tags will be executed if specified.monochrome
: A boolean value indicating if console output should be one color. (Defaults to false)strict
: A boolean value indicating whether scenarios should be evaluated strictly. (Defaults to false)dryRun
: A boolean value indicating whether scenarios should be run as a dry run. (Defaults to false)
cucumber {
formats = ['pretty','json:build/cucumber.json','junit:build/cucumber.xml']
glueDirs = ['src/test/resources/env',
'src/test/resources/support',
'src/test/resources/step_definitions']
featureDirs = ['src/test/resources/features']
tags = ['@billing', '@important']
monochrome = false
strict = false
dryRun = false
}
The "asyougo" formatter is a hacked "pretty" formatter, which displays scenario lines as they are evaluated.
cucumber {
formats = ['asyougo']
}
You must use cucumber version 1.1.5 or higher.
- Windows support
- Idea integration: Cucumber source dirs automatically added to modules with test scope
- Automatic dependency retrieval and default glue dirs for each jvm language
- Simplified task configuration
- Command-line arguments to override task configuration
./gradlew \
-Psigning.secretKeyRingFile=path/to/ring.gpg \
-Psigning.keyId=GPG_KEYID \
-Psigning.password=$GPG_PASS \
-PsonatypeUsername=$SONATYPE_USER \
-PsonatypePassword=$SONATYPE_PASS \
clean uploadArchives
It is possible to save some or all of those properties to ~/.gradle/gradle.properties
.