2

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 .
vaishakh
  • 176
  • 2
  • 2
  • 14

2 Answers2

2

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.

0
  • I have a similar experience and i realized that if i don't use 1:1 mapping of feature to step definition file then it results in step_def not found errors e.g.pytest_bdd.exceptions.StepDefinitionNotFoundError: Step definition is not found:
  • So, I stick with the safe approach of 1:1 mapping
  • Would like to hear more thoughts feedback on this
philomath
  • 113
  • 2
  • 9
  • 1
    I have switched to behave bdd as it offers more flexibility and I can map 1 feature file to multiple step definition file – vaishakh Mar 04 '21 at 05:05
  • @vaishakh , could you please tell me how to map a feature file to a steps file ? are we supposed to use tags or something. I am not able to figure out how to map a particualr feature file with a particular stepfile – Zenith_1024 Feb 10 '22 at 06:52
  • @Raytheon_11 We don't have to explicitly map a feature file with steps file, behave bdd would automatically detect unique steps and map internally. It basically searched for all the steps file inside the steps folder to find a relevant match. – vaishakh Nov 15 '22 at 03:37