pytest-dev / pytest-dev/pytest-bdd
How to use parameterized fixtures in pytest-bdd
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 251
- Avg merge
- 43m
- Merged PRs (30d)
- 2
Description
I am trying to use parameterized fixture in my pytest-bdd framework. Normal fixture works fine. But If I am passing parameters, it gives below error
""The requested fixture has no parameter defined for test:""
Below is my code(Sample). Waht is the correct usage here?
@pytest.fixture(params=[1,2])
def ba_data(request):
print("this is fixture")
return request.param
@given(parsers.cfparse('Collect testdata'))
def required_data(ba_data):
print(ba_data)
actual need behind this:
I wanted to run entrire scenario multiple times, with dynamically generated data
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the shown parameterized ba_data fixture and the @given step in a minimal pytest-bdd scenario. Read how pytest-bdd resolves fixtures for scenario steps, then verify that the scenario can run multiple times with dynamically generated data without the reported missing-parameter error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100