Gradle cucumber task is not recognizing cucumber steps

690 views Asked by At

My build file looks like below and attaching my folder path. When I run the task, It says undefined steps and Its asking to implement steps again.

enter image description here

I have created my own task in gradle to run cucumber test

task seleniumbddTest() {
    dependsOn assemble, testClasses
    doLast {
        javaexec {
            main = "io.cucumber.core.cli.Main"
            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
            args = ['--plugin', 'html:target/seleniumreport' + getTime() + '.html', '--plugin', 'pretty', '--glue', 'Capsone.steps', 'src/seleniumbdd/resources', '--tags', '@Test']
        }
    }
}
1

There are 1 answers

0
Funky Monkey On

You should add glue path to your configuration. Glue path specifies Cucumber where your stepDefinitons are. Just add another line to your seleniumbddTest class:

glue = "package"

And finally, change "package" with the name of the package where your step definitions are. If your step definitions class is named "steps" and they are under package "stepDefs" , only add "stepDefs" as a glue path. You do not have to provide full path from root.

Also, remove that "--glue" flag from your args

Good luck :)