automationpytestpytest-bdd

How to link Feature File to multiple step defintion files in Python BDD



I am developing a framework for automation using pytest-bdd based framework. Based on functionality I have multiple feature files and multiple step defintion files. Some scenarios take steps from other step definition files.
For example I have a Login Module , User Details Module. Now for validation of a step in User Module I do have to start with steps from the Login Module.
However in python bdd, I could see a one to one mapping of feature and step definition file. Please let me know if this a limitation of pytest bdd framework .

Solution

  • Yes as far as i have worked with pytest bdd, you can only map one step definition to a single feature file, but there are work arounds to these.

    1.Use conftest to keep all your common steps that you want to call across multiple feature files. 2.Use methods to be called into other step definitions by importing those methods into other step definitions.