I'm setting up a Cucumber + Java project with the following project structure:
My configuration correctly maps the main class, feature folder and glue is mapped to "stepdefs".
However, when trying to run the tests, I'll get the Cucumber's "Step undefined" message:
Step undefined
You can implement missing steps with the snippets below:
@Given("user is on the homepage")
public void user_is_on_the_homepage() {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
I noticed the class name in Steps.java
file is highlighted and complaining that "Step definition class must be in named package":
I tried just adding package stepdefs
to the top of the file, but that doesn't seem to work ("stepdefs" will be underlined and with note "Package name 'stepdefs' does not correspond to the file path ''").
UPDATE:
After some suggestions from @tashkhisi here is my new project structure:
First following link is very useful for getting started with cucumber I suggest you to follow that link for better explanation.
But Here this should be your directory structure I suggest you to use conventional name but if you are determined to do that do this: mark stepsdef as Test Source Root directory
UPDATE:
your main directory must be test and not main.
Where is the @RunWith(Cucumber.class) annotatioon for running your test?
Why don't you use following command to create the best directory structure?
Inside java and resource you shoud have the same directory structure
mvn archetype:generate \
"-DarchetypeGroupId=io.cucumber" \
"-DarchetypeArtifactId=cucumber-archetype" \
"-DarchetypeVersion=5.6.0" \
"-DgroupId=hellocucumber" \
"-DartifactId=hellocucumber" \
"-Dpackage=hellocucumber" \
"-Dversion=1.0.0-SNAPSHOT" \
"-DinteractiveMode=false"