pytest-dev / pytest-bdd

BDD library for the pytest runner
https://pytest-bdd.readthedocs.io/en/latest/
MIT License
1.31k stars 221 forks source link

Background steps stopped working after adding another Given - StepDefinitionNotFoundError #336

Closed PeterAugustinak closed 5 days ago

PeterAugustinak commented 5 years ago
  1. put common steps out of feature step_def file for re-usability purposes
  2. run tests

Result: step definitions are not found. IDE (like Pycharm) has no problem to localize these steps. pytest-bdd can see common steps only in conftest.py. In case to place them to any other file with completely correct definitions (like common_steps.py), it is not working.

youtux commented 4 years ago

you should import those steps in your conftest.py:

# conftest.py
from tests.common_steps import *
xiaorong22 commented 1 year ago

you should import those steps in your conftest.py:

# conftest.py
from tests.common_steps import *

thanks a lot, very useful for me

jsa34 commented 5 days ago

Answer given by @youtux appears to resolve and documentation suggests using conftest.py for shared steps.