使用pytest-bdd背景设置多行

问题描述 投票:2回答:1

我想使用pytest-bdd编写类似小黄瓜的测试,以为某些功能创建一组通用的测试数据。我无法使用given添加多行,因为“已使用给定的步骤”。什么是正确的方法?

我尝试过:

    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"

此操作失败,并显示以下消息:

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.
python pytest bdd pytest-bdd
1个回答
0
投票

'嗨,您在conftest.py文件中的步骤定义是什么?背景:标题` 给定一些 还有其他 还有更多'在conftest.py中应该是

@@ given(“某物”)enter code heredef something(): '你的代码的东西 通过

@@ given(“其他”))def something(): '你的代码的东西 通过

@@ given(“还有其他东西”)def something(): '你的代码的东西 通过

© www.soinside.com 2019 - 2024. All rights reserved.