All Collections
Behave Pro Classic
Build Tools
Cucmber-JVM With Gradle (Java)
Cucmber-JVM With Gradle (Java)

Export features and scenarios for test automation with Cucumber when using Gradle as your build tool

Alan Parkinson avatar
Written by Alan Parkinson
Updated over a week ago

Behave Pro can export the created Feature and Scenarios to any gherkin compatible test automation tool. For Gradle based projects we have a taks that will export the features directly from Jira based your projects tasks dependencies.

Gradle task

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 build script 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 = ' for Cloud OR Jira Server URL'
    username = 'Cloud userId OR Jira Server User'
    password = 'Cloud API key OR Jira Server Password'
    destinationDir = 'build/generated-test-sources/cucumber'

The task has four required parameters, server , projectKey , username  and password . These 4 parameters are different depending on if you are using Jira Cloud or Server. You can retrieve the correct details the Jira project's admin area; 'Project Settings' > 'Behave Pro' > 'Generate config'. This article has more information on finding these configuration items

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']
Did this answer your question?