Issue with pytest-bdd execution after python and pytest-bdd version upgrade

14 views Asked by At

I am using pytest 7.0.0, python 3.11.1 and pytest-bdd version to 7.0.0 and I am able to run one test case by hardcoding values of conf and id in pytest fixtures in test_abc.py def conf() and def id() but I can hardcode only one values. How can I parameterize these fixtures so that it should pick values from feature file test cases and send to given statement every time based on test case execution.

when 1st test case to be executed, it should pick abc.cfg and load 1 and when 2nd test case will be executed, it should pick xyz.cfg and load 2 and so on.

This is feature file sample abc.feature

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 |

@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)

0

There are 0 answers