pytest 8.3.2,pytest-bdd=7.2.0
这是我的功能文件:
Feature: Blog
A site where you can publish your articles.
Scenario: Publishing the article
Given "test" the application
以下是步骤定义文件。但是当我运行它时,我遇到了问题,因为找不到固定“短语”。不知道为什么它期望这里的固定装置。我现在不想拥有适合我的场景的固定装置。
scenario('../features/test_app.feature', 'Publishing the article')
@given(parsers.parse(" {phrase} the application"))
def test_app(phrase):
print(phrase)
我希望函数中传递的参数应该被传递
当您运行
pytest
(安装或不安装pytest-bdd
)时,它会执行以test
开头的所有功能。步骤定义函数的名称是 test_app()
,因此它被选为普通(非 BDD)pytest 测试函数。
您所需要做的就是重命名该函数!
编辑:此外,在解析的句子开头有一个额外的空格 - 您需要将其删除才能正确匹配步骤定义。