Forum Discussion

jayanth070782's avatar
New Contributor
4 years ago

Reusability of Gherkin Feature File

Can we call one feature file scenario in another feature file

Ex: Say we use Login in every Feature file to test scenarios for different application functionalities. To increase reusability we can design login as reusable component i.e. in case of cucumber we could create scenario within feature file just for login and call the file so in case something changes we need to update 1 feature file rather than updating n number of feature file. Is this something possible??


In case if this is not supported and we are writing E2e workflow as scenarios what’s the best practices to reduce maintenance and increase reusability

1 Reply

  • Actually that depends on your own implementation.


    Feature file are not code. They are structured documentation.


    Cucumber Open allows you to add implementation to your features as part of step definitions and hooks, thus to interact with the system under test.


    That means that, based on your example around the login, you could have a support method somewhere which logged a user in. That method could be called in a step as part of a scenario dedicated to test the login process for your user. And that exact same method could be called in hooks, or a step of a background, for other scenarios where the user should be logged-in.