gradle-cucumber-plugin icon indicating copy to clipboard operation
gradle-cucumber-plugin copied to clipboard

Running cucumber task - problem with step definitions

Open ibrahim-innovid opened this issue 9 years ago • 4 comments

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.

ibrahim-innovid avatar Sep 20 '15 08:09 ibrahim-innovid

+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

mcandre avatar Oct 14 '15 14:10 mcandre

// 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') } }

rgylan avatar May 28 '19 11:05 rgylan

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.

gregmunt avatar May 28 '19 14:05 gregmunt

Is this still an issue?

gregmunt avatar Nov 23 '19 22:11 gregmunt