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

Import from steps with a target_fixture collects the same test twice? #630

Closed AmirYa412 closed 1 year ago

AmirYa412 commented 1 year ago

I am working on a refactoring a project from Behave to pytest-bdd. Structure looks like this:

|---features
|          |---publish.feature
|---steps_def
|          |---conftest.py
|          |---test_article.py
|          |---test_publish.py     # scnearios() defined here

We have an internal Driver we initialise in conftest.py In test_article.py I have steps that can be related to all features, "common steps". I want to use defined steps freely in feature files, and use their target_fixture between other steps files.

I noticed few issues that stopping us from fully moving to pytest-bdd:

xiaorong22 commented 1 year ago

I encountered the same issue. I will keep an eye on it. next is the structure of my projects:

`

features: | -- test.feature | -- conftest.py: import all the functions from 3 test_steps py files | -- steps_def

| -- test_step1.py | -- test_step2.py | -- test_step3.py`

my problem is: when the project has 3 test_step.py files, the report is: 3 passed, 18 deselected, 2 warnings but if I remove test_step3.py, and run the case again, the report is: 2 passed, 12 deselected, 2 warnings

xiaorong22 commented 1 year ago

I found you have already closed the issue. so could you tell me how to resolve this issue? thanks a lot!!