Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Use correct CucumberOptions

RunCukesTest used wrong import wrongly.
latest commit 0f5a440cde
@judoole judoole authored
..
Failed to load latest commit information.
src Use correct CucumberOptions
.gitignore Words/tweaks
README.md Words/tweaks
build.gradle Use --plugin in build.gradle

README.md

Running Cucumber-JVM with step definitions in Java using Gradle's javaexec task

Credits

This work is based on dkowis/cucumber-jvm-groovy-example

Motivation

There exists a number of issues which prevent seamless integration of Cucumber-JVM and Gradle.

Solution

One possible solution is to use Cucumber's Main class to run your tests. You can do this by using the javaexec task in Gradle.

Running

In order to run your Cucumber tests execute:

gradle cucumber

Caveats

The Groovy example by David Kowis runs perfectly, but it uses Groovy step definitions.

If you're writing your step definitions in Java then the Gradle script needs to be changed slightly.

Here are some caveats:

  • The cucumber task has to depend on compileTestJava task in order to compile test sources

    task cucumber() {
       dependsOn assemble, compileTestJava
       ...
    }
  • The javaexec classpath should include main and test output directories. Otherwise Cucumber-JVM will not find your production classes/resources and step definitions respectively.

    classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
  • Cucumber's --glue should be set to your package name (e.g. gradle.cucumber) and NOT to src/test/java

    args = ['-f', 'pretty', '--glue', 'gradle.cucumber', 'src/test/resources']
Something went wrong with that request. Please try again.