Comments (6)
You have to use the target_fixture=“conf” parameter. Che the migration guide to pytest-bed v7 in the readme of the project.
from pytest-bdd.
yes I have used that but again stuck with parametrization of conf and id values from all the test cases. I am able to hardcode one specific conf and id value in conf and id fixtures.
Feature: load
Background:
Given config file <conf> for product "ETMARGIN" and TestCaseld <id>
@tc
Scenario Outline: tc1
Then data between source file and table should match
Examples:
| conf | id |
|abc.cfg |load1 |
|def.cfg |load3 |
@tc
Scenario Outline: tc1
Then data between source file and table should match
Examples:
| conf | id |
|xyz.cfg |load2 |
This is test case file sample: test_abc.py
from pytest bad import scenarios, given, when, then, parsers
import pytest
import os
scenarios("./feature/")
def check():
print("passed")
@pytest.fixture
def conf():
return 'abc.cfg'
@pytest.fixture
def id():
return 'load1'
@given(parsers.parse('config file <conf> for product "(product)" and TestCaseld <id>'))
def job_details(conf, product, id):
print(conf + product + id)
from pytest-bdd.
I think I can not do it or is there any other way because this is what I got to know from documentation:
(https://pytest-bdd.readthedocs.io/en/stable/#refuse-combining-scenario-outline-and-pytest-parametrization)
The significant downside of combining scenario outline and pytest parametrization approach was an inability to see the test table from the feature file.
from pytest-bdd.
Sorry, I don’t understand what you’re trying to do here
from pytest-bdd.
@youtux - Sorry for late reply. What I am trying to do here is I am trying to pass the parameter values from scenario outline examples to the given statement in test case in test_abc.py.
What I showed you in above comment is I am able to pass abc.cfg and load1 to the given statement by hardcoding it in test_abc.py using conf and id fixtures but how should I pass other scenario outline examples like def.cfg & load3, xyz.cfg and load2 in feature file to the given statement in test_abc.py?
Isn't there any way to parameterize these scenario outline examples in test_abc.py so that and in given, when and then statemen test cases in test_abc.py should pick up these outline examples values from conf and id from feature file when it comes to execution?
I am able to achieve using pytest-bdd 4.1.0 and python 3.10.10 but unable to do so in upgraded versions.
If you can help, then that would be really great. I couldn't find any solution of this anywhere not even using AI tools.
from pytest-bdd.
Have you tried:
@dataclass
class JobDetails:
conf: str
product: str
id: str
@given(parsers.parse('config file <conf> for product "(product)" and TestCaseld <id>'), target_fixture=“job_details”)
def _(conf, product, id):
return JobDetails(conf, product, id)
then in your given/when/then steps you can use the job_details
fixture
from pytest-bdd.
Related Issues (20)
- RFE: is it possible to restart making github releases?🤔 HOT 2
- How to use multiple values for a parameter in Scenario Outline Examples
- Custom hooks HOT 1
- Issue with pytest-bdd Failing to Identify Correct Scenario Path After Folder Name Change HOT 2
- `iterparentnodeids` removed from pytest HOT 1
- Step definition parses wrong parameter from feature file
- Unable to run parallel tests with pytest-xdist - can't serialize <class 'pytest_bdd.parser.Step'> HOT 1
- Pytest emits deprecation warning: "A private pytest class or function was used" HOT 3
- pytest-bdd doesn't support pytest 8.1.0 HOT 5
- Missing git tags for 7.1 and 7.1.1 releases HOT 1
- Python 3.8/pytest 3.0.4/pytest-bdd 3.1.0 crash: TypeError: an integer is required (got type bytes) HOT 2
- Pytest 8.1.1 fixture injection compability HOT 2
- Unable to run pytest-bdd with pytest-xdist, can't serialize <class 'pytest_bdd.parser.Step'> HOT 4
- Does pytest-bdd support pytest-xdist? HOT 2
- Version 7.1.2 no longer provides pytest_bdd.steps.inject_fixture HOT 1
- Re-use of target_fixture not possible anymore HOT 1
- How to apply for function/module/package/session scope to feature HOT 2
- Is there a hook for 'before_feature' in pytest-bdd?
- Multiple step scenarios targeting the same fixture doesn't update the fixture HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-bdd.