pytest-dev / pytest-dev/pytest-bdd

Rewrite pytest-bdd to use hooks and marks

Open
#310 8 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
251
Avg merge
43m
Merged PRs (30d)
2

Description

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:

# test_some_scenario.py
pytestmark = pytest.mark.scenarios('a.feature')

# override "Scenario 3"
@pytest.mark.scenario('a.feature', 'Scenario 3')
def test_a_scenario(...):
    # do something more
    pass

instead of the current way:

import pytest_bdd

# override "Scenario 3"
@pytest_bdd.scenario('a.feature', 'Scenario 3')
def test_a_scenario(...):
    # do something more
    pass

scenarios('a.feature')

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 and then 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading issue #296 and the linked pytest documentation on marks and hooks, then compare the proposed API with the current pytest-bdd decorators shown in the issue. Determine whether the rewrite can preserve existing features and decide the role of the @scenario mark; done requires an agreed design and implementation plan.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.