表现,打印出场景编号

时间:2017-06-26 05:36:48

标签: bdd python-behave

上下文:我正在使用带有Behave的Python(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信息。 有什么方法可以告诉他们在运行时打印出这些信息吗?

1 个答案:

答案 0 :(得分:2)

这取决于你如何做出断言。但您可以从docs中找到的信息中实现它。我按照描述here设置了一个behave.ini,因此出现了print,然后将其添加到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并在异常上运行最后一行。