gradle-cucumber-plugin
gradle-cucumber-plugin copied to clipboard
Running cucumber task - problem with step definitions
Hi.
I have the path: src/test/resources/feature/... which has *.feature files which are the test files and I have their step definitions in: src/test/java/feature/...
Before using the cucumber plugin, I could run ./gradlew test and it would run the test successfully.
Now I run ./gradlew cucumber and it finds the tests, but not the step definitions. Instead, it suggests to implement missing steps with the snippets below(giving examples of how step defs should be)
Why's that? why it doesn't locate the step definitions under the src/test/java/feature.. path?
And how could I change the configuration so it'd work?
In addition, I'd like to know how could I run specific tests which exist under specific folders? for example,tests which exists in folders of which the names are prefixed with "example"? All of that using ./gradlew cucumber task! Is it possible?
Thanks in advance.
+1
The README has confusing and conflicting instructions for where the gradle-cucumber-plugin actually looks for step definitions.
Could we please link to a mini project as a complete example?
As it happens, StackOverflow's layout is correct:
http://stackoverflow.com/a/32906314/5120509
Example:
https://github.com/mcandre/hello-kafka
// Exclude cucumber tests below when running test, build tasks. test { exclude '/integration/' }
// Cucumber tasks. configurations { cucumberRuntime { extendsFrom testImplementation } }
ext.RunFeature = { String definition, String feature -> javaexec { main = "cucumber.api.cli.Main" classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output args = ['--plugin', 'pretty', '--glue', definition, feature] } } // Configure your feature to run from here. project.tasks.create('cucumber') { dependsOn assemble, compileTestJava doLast { RunFeature('your.definition.package1', 'src/test/resources/features/basicTemplate.feature') RunFeature('your.definition.package2', 'src/test/resources/features/advanceTemplate.feature') } }
Looking at the code, the default glue dir seems to be src/test/java and the default feature dir seems to be src/test/resources. However, in my own use of the plugin, I generally specify src/cucumber/groovy as the glue dir and src/cucumber/resources/features as the feature dir. My preference is to keep unit tests and acceptance tests in separate source sets.
Features will be found from all subdirectories of the feature dir. The original poster had glue code under src/test/java/feature - this would not have been found unless the default dir was overridden, or step definitions were in a 'feature' package.
Is this still an issue?