Java with Gradle

Java with Gradle

The Gradle task can be installed automatically by configuring your Gradle scripts to fetch the task and its dependencies using standard Maven resolution.

buildscript {
    repositories {
        maven { url '' }
    dependencies {
        classpath group: 'com.hindsighttesting.behave', name: 'behave-gradle-task', version: '1.0.0-1'

The above script will automatically download the task from the Hindsight Maven repository, and make it available to the buildScript of your projects.


Adding a task to download Acceptance Tests from Behave

To download the Acceptance Tests (Feature files) you need to create a task implementing "com.hindsighttesting.behave.gradle.FeaturesTask". This type has been added by the automatic installation described above.

task behavefeatures(type: com.hindsighttesting.behave.gradle.FeaturesTask) {
    projectKey = '10100'
    server = ''
    username = 'aalyYToxMDgzMjAyMM=='
    password = '834a65e809a0ab22696e7e307d222a4887aa0078'
    destinationDir = 'build/generated-test-sources/cucumber'

Configuring Cucumber

Don't forget to execute the Behave Download Task before executing Cucumber, or you won't have any tests to execute. This can be simply done by adding a dependency from your Cucumber task to the Behave Task.

dependsOn assemble, behavefeatures

Also you will need to tell Cucumber where to find the Acceptance Tests (Feature files) you have downloaded (The "destinationDir" property in the Behave Task)

args = ['-f', 'pretty', '--glue', 'build/classes/test', 'build/generated-test-sources/cucumber']
  1. Prev
  2. Next