Python Behavior BDD框架。当一个步骤失败时如何执行剩余步骤 [英] python behave bdd framework. how to execute remaining step when a step fails
本文介绍了Python Behavior BDD框架。当一个步骤失败时如何执行剩余步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是pythonbdd框架。其中,即使有一个步骤失败,我也需要继续执行其余步骤。
Scenario Outline: Components
Given I load the website
When I go to "Dashboard" page
Then I see this component "<boxes>"
当上述场景中的第二步失败时。我希望继续下一步,即使上面的步骤失败了。如何继续
推荐答案
例如,您可以将标记@runner.continue_after_failed_step
添加到您的方案中,并将以下代码添加到您的环境中。py:
from behave.model import Scenario
def before_scenario(context, scenario):
if "@runner.continue_after_failed_step" in scenario.effective_tags:
scenario.continue_after_failed_step = True
或者,如果您想要在所有方案的失败步骤后继续执行,只需将以下代码添加到您的环境。py:
from behave.model import Scenario
def before_all(context):
userdata = context.config.userdata
continue_after_failed = userdata.getbool("runner.continue_after_failed_step", False)
Scenario.continue_after_failed_step = continue_after_failed
并将这些参数添加到根目录下的behavive.ini文件中:
[behave]
show_timings = false
[behave.userdata]
runner.continue_after_failed_step = true
如果您需要更多信息,可以在这里找到Behavior项目的实现Behave Github
这篇关于Python Behavior BDD框架。当一个步骤失败时如何执行剩余步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文