Skip to content

Example project which shows how to run Cucumber-JVM with step definitions in Java using Gradle `javaexec` task.

Notifications You must be signed in to change notification settings

snagis/cucumber-jvm-gradle-javaexec

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Running Cucumber-JVM with step definitions in Java using Gradle 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 javaexec task in Gradle.

Running

In order to run your Cucumber tests execute:

gradle cucumber

Caveats

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

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

Here are some caveats:

  • cucumber task has to depend on compileTestJava task in order to compile test sources
task cucumber() {
    dependsOn assemble, compileTestJava
    ...
}
  • 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']

About

Example project which shows how to run Cucumber-JVM with step definitions in Java using Gradle `javaexec` task.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published