I'm having trouble running Cucumber tests in Gradle. I am using cucumber-jvm.
Class TestNGCucumberRunner
extends the AbstractTestNGCucumberTests
and testng annotations with @beforesuite
, @aftersuite
..
I usually run the TestNGCucumberRunner.java
in IntelliJ by right-click and it runs successfully. Now I want to
or
I tried to execute the TestNGCucumberRunner.java as a javaexec but that fails.
I tried to execute all the feature files in the package. I have used apply plugin: 'com.github.samueltbrown.cucumber'
also.
My new setup uses a different plugin that supports parallel execution of scenarios, better reporting, and is still actively maintained:
build.gradle
plugins {
...
id "com.commercehub.cucumber-jvm" version "0.11"
}
addCucumberSuite 'cucumberTest'
dependencies {
...
cucumberTestCompile 'info.cukes:cucumber-java:1.2.5' // or -java8 if you prefer lambda notation
}
directory structure:
└── src
├── cucumberTest
│ ├── java
│ │ └── package1
│ └── <- Glue
│ └── resources
│ └── package2
│ └── <- Features
├── main
│ └── java
└── test
└── java
package1 and package2 names (together with many other options) can be specified in the build.gradle file
My previous setup for using cucumber for java with gradle.
build.gradle
plugins {
id "java"
id "com.github.samueltbrown.cucumber" version "0.9"
}
dependencies {
cucumberCompile 'info.cukes:cucumber-java:1.2.4'
}
cucumber {
formats = ['pretty','junit:build/cucumber.xml']
}
Directory layout
└── src
├── cucumber
│ ├── java <- Glue
│ └── resources <- Features
└── main
│ └── java
└── test
└── java
Command
gradle cucumber