pytest-dev / pytest-bdd

BDD library for the pytest runner
https://pytest-bdd.readthedocs.io/en/latest/
MIT License
1.31k stars 221 forks source link

Get pytest_bdd.exceptions.FeatureError: Step definition outside of a Scenario or a Background when I write double when-then in my feature. #625

Closed shihai1991 closed 1 year ago

shihai1991 commented 1 year ago

for example, there has a test.feature:

Feature: test_feature

  Background:
    When test_when
    Then test_then
    When test_when
    Then test_then

when I use scenarios("test.feature") import the features, I got this error.

Step definition outside of a Scenario or a Background

the error will gone if I use a single When-Then in feature:

Feature: test_feature

  Background:
    When test_when
    Then test_then
shihai1991 commented 1 year ago

releated discussion: https://github.com/pytest-dev/pytest-bdd/issues/408