I have created one feature file which has 4 scenarios. Do I need to create 4 step definitions or only 1?

If 1 then is it ok to have multiple @Given, @When and @Then in one step definition?

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

by (142 points)
0 votes

It depends on the complexity of the elements in page. If the scenario involves interaction with elements in multiple pages, or a single page having too many elements then it’s better to split into multiple step definition classes. This will help out in maintaining your tests well versed

Currently working on a PoC for BDD with Specflow + NUnit so my take always are

1. Multiple scenario with single Feature file

2. Common Step definition file for generic functions

3. Generic file for handling utils functions