3

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:

    Background:
        Given a user with Clerk privileges
        And a household entry for "Alice" with SubmissionDate "Nov 26, 2019 3:59:50 pm"
        And a household entry for "Bill" with SubmissionDate "Nov 27, 2019 3:59:50 pm"

This fails with the message:

E pytest_bdd.exceptions.GivenAlreadyUsed: 
Fixture "add_household" that implements this 
"a household entry for "Bill" with SubmissionDate "Nov 27, 2019 3:59:50 pm"" 
given step has been already used.
Michael Grazebrook
  • 5,361
  • 3
  • 16
  • 18

1 Answers1

1

Hi what is your step definition in your conftest.py file ?

Background:Title
    Given something
    And something else
   And something more

in conftest.py it should be

@given("something")
def something():
    # your code for something
    pass

@given("something else")
def something():
    # your code for something
    pass


@given("something more")
def something():
    # your code for something
    pass
HK boy
  • 1,398
  • 11
  • 17
  • 25
Sandeep
  • 34
  • 4