Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running cucumber task - problem with step definitions #46

Open
ibrahim-innovid opened this issue Sep 20, 2015 · 4 comments
Open

Running cucumber task - problem with step definitions #46

ibrahim-innovid opened this issue Sep 20, 2015 · 4 comments

Comments

@ibrahim-innovid
Copy link

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.

@mcandre
Copy link

mcandre commented Oct 14, 2015

+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

@rgylan
Copy link

rgylan commented May 28, 2019

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

@gregmunt
Copy link
Collaborator

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
Copy link
Collaborator

Is this still an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants