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

Undefined steps when running gradle cucumber #68

Open
poornima-ns opened this issue Apr 18, 2017 · 4 comments
Open

Undefined steps when running gradle cucumber #68

poornima-ns opened this issue Apr 18, 2017 · 4 comments

Comments

@poornima-ns
Copy link

Referenced from #27 #27 (comment) as it is closed.

Hi @viphe I am also having the similar problem when I used gradle cucumber it complained steps are undefined. I am using cucumber-jvm with scala. I am using this plugin version 0.9, cucumber version is 1.2.5 and my gradle version is 3.5. I added the glueDirs as classpath: and also hard coded the path but it still says steps are undefined. Any progress on this issue?

cucumber {
  formats = ['pretty','json:build/cucumber.json']
  glueDirs = ['classpath:step_definition_package_name']
  featureDirs = ['path_to_feature']
  tags = ['@wip']
  monochrome = false
  strict = false
  dryRun = false
  ignoreFailures = false
  jvmOptions {}
}

When I added a task as below in build.gradlew file and ran with new task, the tests run

task cucumber12(type: JavaExec, dependsOn: assemble ) {
  main = "cucumber.api.cli.Main"
  classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
  args = ['-f', 'json:build/reports/cucumber/cucumber.json', '--glue', 'step_definition_package_name', 'path_to_feature']
}

Why I am not able to use this plugin but able to run via new task added?

@jacek99
Copy link

jacek99 commented Oct 2, 2017

Same here. Is not able to find my Java step definitions.
I have step definitions in

src/test/java/com/myapp/test/cucumber/StepDefs.java

and the feature file in

src/test/resources/com/myapp/test/cucumber/test.feature

When I run the task it finds the feature, but says all the steps are uninplemented.
If I run using the JUnit test runner, it finds the steps without any problems and executes the BDD correctly.

My config

cucumber {
    formats = ['pretty','junit:build/cucumber.xml']
    glueDirs = ['src/test/java']
    featureDirs = ['src/test/resources']
    tags = []
    monochrome = false
    strict = false
    dryRun = false
    ignoreFailures = false

    jvmOptions {
        maxHeapSize = '512m'
    }
}

@bindulaxminarayan
Copy link

As soon as I upgraded from gradle 2.8 to 4.3, the step definitions are not being recognized.

tasks.cucumber {
formats = ['pretty', 'json:build/cucumber-tests/cucumber.json', 'html:build/cucumber-tests/cucumber_results.html']
}

@mariaanko
Copy link

mariaanko commented May 18, 2021

I know that this is an old thread, but I also had a problem running the cucumber gradle task...

task cucumber() {
    dependsOn assemble
    doLast {
        javaexec {
            main = "io.cucumber.core.cli.Main"
            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
            args = ['--plugin', 'pretty', '--glue', 'hellocucumber', 'src/test/resources']
        }
    }
}

the --glue switch in this gradle task arguments is what I had to change to fix the issue.
I changed "hellocucumber" to the correct package name I'm using in my project...I hope it helps someone who finds this thread in the future.

@jdmesalosada
Copy link

jdmesalosada commented Sep 14, 2022

I know that this is an old thread, but I also had a problem running the cucumber gradle task...

task cucumber() {
    dependsOn assemble
    doLast {
        javaexec {
            main = "io.cucumber.core.cli.Main"
            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
            args = ['--plugin', 'pretty', '--glue', 'hellocucumber', 'src/test/resources']
        }
    }
}

the --glue switch in this gradle task arguments is what I had to change to fix the issue. I changed "hellocucumber" to the correct package name I'm using in my project...I hope it helps someone who finds this thread in the future.

I was having the same issue I had to put the full package path instead of just "hellocucumber" ' so at the end got --glue', 'com/jmconsultant/hellocucumber'

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

5 participants