-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite pytest-bdd to use hooks and marks #310
Comments
I use |
@Vic152 @Vic152 fair enough, but I would intend to still support running pre-test and post-test actions by using fixtures instead. So potentially your code would transform from this: @scenario('a.feature', 'A scenario')
def test_a_scenario():
do_cleanup() to this: pytestmark = [
pytest.mark.scenarios('a.feature'),
pytest.mark.usefixtures('cleanup_fixture'),
]
@pytest.fixture
def cleanup_fixture():
yield
do_cleanup() # This would be run at the the end of each test |
@youtux |
@youtux please review ideas from elchupanebrej#33 , they could be a good basement for this feature.
|
Also, we could auto-collect Feature files using https://docs.pytest.org/en/7.1.x/example/nonpython.html ideas. |
Yes, I wanted to do that for quite some time already, but never had the time to dig into that. |
I'll try to implement PoC fo auto import in the nearest future |
@youtux please check the approach from elchupanebrej#74 and share your thoughts. That PR also uses ideas from #342 #542 |
Following the suggestion from issue #296, I will try to re-implement pytest-bdd to use marks and hooks.
I imagine an API that will look like this:
instead of the current way:
I yet don't know if this is entirely feasible without breaking other features, but we will see.
Short note about
@scenario(...)
Potentially, I will also remove the single scenario mark/decorator, given that the only thing it allows to do is to require some more fixtures before the scenario is run, and to execute some more logic after the scenario finished.
This custom logic can already be implemented using
given
andthen
steps, but I understand that sometimes it can be just some compensation logic that should not appear in the feature file.I still didn't figure out what to do with this, so probably I'll keep the
@scenario
mark/decorator for the time being.@bubenkoff @olegpidsadnyi @sliwinski-milosz: Feedback on this idea would be appreciated.
The text was updated successfully, but these errors were encountered: