2

As per my understanding, a single step definition file methods can be reused by steps with the same name in other feature files.

then, what is the purpose of splitting a single cucumber Step Definition file into multiple step files?

2 Answers 2

4

Same reason why you would split large modules in your regular code base: maintainability & navigability.

Over time as your step definitions grow you will have steps that are closely related to certain parts or functionalities of your system, but not related to other steps in the step definitions. Once the file becomes large enough it will become harder to maintain and find the steps you are looking for. That's a great indicator that you should starting splitting up in multiple step definition files. For small projects, you may never reach this size.

1

To cope with the complexity and ease of maintenance.

Once we reach a size where it becomes difficult to maintain a single step definition file, then we split generally based on per page object however as we need to maintain state, we need to create global objects like webdriver and page objects and share the reference of the objects between files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.