【问题标题】:Behave , print out scenario number行为,打印出场景编号
【发布时间】:2017-11-28 22:24:40
【问题描述】:

上下文:我正在使用 Python with Behave (BDD)。 我的 .feature 文件如下所示:

@ISA-75 
@ISA-76
@1
@1.1
Scenario: A user will be able to enter an email address to receive a notification when a requested archive is complete.
  Given ...
  When ...
  Then ...

运行的输出不包含@1 或@1.1 信息。 有什么方法可以告诉行为在运行时打印出该信息?

【问题讨论】:

    标签: bdd python-behave


    【解决方案1】:

    这在某种程度上取决于您如何做出断言。但是您可以从他们的docs 中找到的信息中实现它。我按照here 的描述设置了一个behave.ini,所以出现了打印,然后将其添加到environment.py文件中。

    def after_scenario(context, scenario):
        if context.failed == True:
            print(context.scenario, 'failed. Here are the tags:')
            for tag in context.tags:
                print(tag)
    

    您可能只是在断言上使用 try/catch 并在异常时运行最后几行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-04
      • 1970-01-01
      • 2016-09-12
      • 1970-01-01
      相关资源
      最近更新 更多