【问题标题】:Behave BDD reusing steps from common step file表现 BDD 重用来自公共步骤文件的步骤
【发布时间】:2022-09-27 21:43:18
【问题描述】:

我如何重用来自 common_step.py 的步骤 例子:

共同特征:

给定使用 \"abc\" 用户登录

common_step:

@given(\'用\"{user}\"用户\'登录)

anotherFile_feature

使用 \"xyz\" 用户登录

另一个文件步骤:

我如何在这里传递那个 xyz 用户,我可以举个例子吗

谢谢

    标签: python-behave


    【解决方案1】:

    如果您需要在其他步骤或部分代码中重用用户,您不应该将用户的值分配给变量吗?

    @given('log in with "{user}" user')
    def do_login(context, user)
        context.user = user  # the context variable will be accessible during execution time
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-13
      • 2022-10-05
      • 2022-06-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多