I am writing automated tests with Cucumber and Java.
I can run the step definitions by right-clicking on my Feature file, and running it as a Cucumber Feature, and all steps pass successfully.
But, I need to run them using a Runner Class.
My feature file is in this folder:
src/test/java/features
And my step definitons are in this folder:
src\test\java\com\abc\commercial\def\automation
My Runner Class is also stored in
src\test\java\com\abc\commercial\def\automation
And here is the Runner Class code:
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"progress",
"html:build/report/html",
"junit:build/report/junit/cucumber-report.xml",
"json:build/report/json/cucumber-report.json"
},
glue = {"src\\test\\java\\com\\abc\\commercial\\def\\automation"},
features = {"src/test/java/features"}
)
public class QARunner {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
When I run the Runner Class as a JUnit Test, I receive the following response in the console:
UUUUUUUUU
Undefined scenarios:
src/test/java/features/US46052
src/test/java/features/postFeatures.feature:43 # As the
2 Scenarios (2 undefined)
9 Steps (9 undefined)
0m0.303s
You can implement missing steps with the snippets below:
@Given("the Application...")
public void the_Application...() {
So the step definitions are not being picked up.
Does it have something to do with where my test runner is located? I don't think it is picking up the step definitons in the automation folder
Thanks for any help
Try this : No need for main method. glue
option should be in package style.
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"progress",
"html:build/report/html",
"junit:build/report/junit/cucumber-report.xml",
"json:build/report/json/cucumber-report.json"
},
glue = {"com.abc.commercial.def.automation"},
features = {"src/test/java/features"}
)
public class QARunner {
}