Pramod Kumar
Pramod Kumar

Reputation: 11

Can I run/use 3 feature files with a single step definition file in cucumber Java

Can I run/use 3 feature files with a single step definition file in cucumber Java? Does cucumber java supports this?

I have the following feature files:

login.feature
registration.feature
search.feature 

I need to implement only 1 step-definition.java file for the 3 feature files.

Upvotes: 1

Views: 575

Answers (2)

Poçi
Poçi

Reputation: 253

You can create a step for one feature and if the step makes sense and the logic is the same you can use it on other feature files without creating another step.

Upvotes: 1

David Baak
David Baak

Reputation: 934

You can use as many or as few files as you want to. But I would recommend splitting your step definitions into classes that correspond with the steps. Here are two suggestions as to how you could do it.

login.feature
registration.feature
search.feature 

LoginStepDefs.java
RegistrationStepDefs.java
SearchStepDefs.java

or per page

login.feature
registration.feature
search.feature 

LoginPageStepDefs.java
RegistrationPageStepDefs.java
SearchPageStepDefs.java
SearchResultPageStepDefs.java

Whatever you choose, make sure your CucumberRunner is configured to pick up the glue code (step definitions).

Upvotes: 1

Related Questions