Questions tagged [pytest-bdd]

86 questions
9
votes
2 answers

Passing parameter from WHEN to a THEN

How do I pass a parameter from a WHEN TO a THEN in pytest bdd? For example, if I have the following code: @when(' is a number divisible by 10') def n1_is_a_number_divisible_by_10(n1): assert (n1 % 10) == 0 newN1 = n1/10 return…
theQuestionMan
  • 1,270
  • 2
  • 18
  • 29
8
votes
0 answers

step definition is not found -- pytest-bdd

I'm trying to set up a pytest-bdd suite for the following feature. Feature: Tree # BUILD TOP-DOWN Scenario: Add properties to tree Given a new tree is created with name default When the name of the tree is asked for Then default is…
David J.
  • 1,753
  • 13
  • 47
  • 96
6
votes
2 answers

pytest fixture not found (pytest-bdd)

I have the following step definitions, which result in an error because the @given fixture is not found, even though it is defined in target_fixture: import pytest from pytest_bdd import scenario, given, when, then, parsers from admin import…
David J.
  • 1,753
  • 13
  • 47
  • 96
4
votes
1 answer

PyTest-BDD Single Scenario Outline Multiple Examples

I'd like to define a single PyTest-BDD based Scenario Outline that has multiple Examples. Sample snippet: Scenario Outline: front to back validation When tester executes access view sql query into av dataframe …
Walter Kelt
  • 2,199
  • 1
  • 18
  • 22
4
votes
0 answers

How to run feature file scenarios through Test Explorer in Python VS Code?

I am trying to run my Behave scenarios in VS Code through test explorer. My feature file and steps file are properly bind as the same project works on Pycharm Professional Edition (trail version). I do not see my test explorer loading my…
3
votes
1 answer

What are target fixtures used for?

@given("employees informations are added", target_fixture="information_db") def ensure_employees_informations_added(): return [_get_employee_information()] My question is will the returned list be saved in "information_db" ? (I am new with…
user14624953
3
votes
1 answer

Using a pytest-bdd background to set up multiple rows

I want to write a gherkin-like test using pytest-bdd to create a common set of test data for some features. I couldn't use given to add multiple rows because "given step has already been used". What's the right way to do this? I tried this: …
Michael Grazebrook
  • 5,361
  • 3
  • 16
  • 18
2
votes
1 answer

How might I use the same step in the same scenario, but with different parameters in pytest-bdd?

Assume I have a scenario similar to this: Scenario Outline: Example scenario Given the subprocess is running When I generate the input And I add to the input And I add to the input …
2
votes
2 answers

How to link Feature File to multiple step defintion files in Python BDD

I am developing a framework for automation using pytest-bdd based framework. Based on functionality I have multiple feature files and multiple step defintion files. Some scenarios take steps from other step definition files. For example I have a…
vaishakh
  • 176
  • 2
  • 2
  • 14
2
votes
2 answers

path does not exist after being created with tmp_path fixture

Edit: here's a git repo for easy testing: https://gitlab.com/qualisign/ugit-bdd/ I want to refactor some repeated code from a step_def file to a conftest.py file. Here's what the step_def looks like: @scenario('../features/CLI.feature', …
David J.
  • 1,753
  • 13
  • 47
  • 96
2
votes
1 answer

why is this method being called twice (pytest)

I have a class called Tree and a class called Property in models.py: class Tree: def __init__(self, name=None): self.name = name self.properties = [] def get_name(self): return self.name def add_property(self,…
David J.
  • 1,753
  • 13
  • 47
  • 96
2
votes
1 answer

Group Page class objects in my step-definition.py for pytest-bdd

I am a beginner to BDD testing using pytest-bdd framework. I am trying to build a framework using Page object model technique. I have created below page class : login.py from selenium import webdriver import time class Login(): def…
Atique
  • 45
  • 6
2
votes
6 answers

Unable to run PyTest-bdd step definition file as it throws index out of range error

Feature file is as below Feature: Nopcommerce Login Scenario: login to nopcommerce website Given nopcommerce page is displayed When user enters username as admin@yourstore.com When user enters password as admin Then user is able to login to…
Lucky1234
  • 129
  • 1
  • 12
1
vote
0 answers

How to do soft assertion in pytest-bdd

Is it possible to do soft assertions in pytest-bdd framwork. Its working without bdd. But with pytest-bdd plug in it fails with below error. (Same test case works fine if I dont use --soft-asserts) INTERNALERROR> …
S_G
  • 67
  • 6
1
vote
0 answers

Pytest bdd cucumber - fetching examples table from excel or csv file

Cucmber BDD - Is there anyway to link the Examples datatable of a Scenario Outline with an external excel file directly from the Feature file in the pytest framework?
spiky_bulba
  • 103
  • 1
  • 5
1
2 3 4 5 6