Python 3.x python行为bdd框架。步骤失败时如何执行剩余步骤

Python 3.x python行为bdd框架。步骤失败时如何执行剩余步骤,python-3.x,cucumber,python-behave,Python 3.x,Cucumber,Python Behave,我正在使用python BDD框架。即使在一个步骤失败后,我仍需要继续执行该步骤的其余部分 Scenario Outline: Components Given I load the website When I go to "Dashboard" page Then I see this component "<boxes>" 场景大纲:组件 假设我加载了网站 当我进入“仪表板”页面时 然后我

我正在使用python BDD框架。即使在一个步骤失败后,我仍需要继续执行该步骤的其余部分

Scenario Outline: Components
        Given I load the website
        When I go to "Dashboard" page
        Then I see this component "<boxes>"
场景大纲:组件
假设我加载了网站
当我进入“仪表板”页面时
然后我看到这个组件“”

当上述场景中的第二步失败时。即使上述步骤失败,我仍希望继续进行下一步。如何继续

例如,您可以添加标记
@runner。在您的场景中添加步骤失败后继续
,并将以下代码添加到您的环境中。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
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
或者,如果要在所有场景的失败步骤后继续执行,只需将其添加到您的环境中即可。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
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
并将这些参数添加到根目录下的behave.ini文件中:

[behave]
show_timings = false

[behave.userdata]
runner.continue_after_failed_step = true

如果您需要有关它的更多信息,您可以在这里的behave project中找到实现。例如,您可以添加标记
@runner。在失败后继续\u步骤
,并将以下代码添加到您的环境中。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
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
或者,如果要在所有场景的失败步骤后继续执行,只需将其添加到您的环境中即可。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
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
并将这些参数添加到根目录下的behave.ini文件中:

[behave]
show_timings = false

[behave.userdata]
runner.continue_after_failed_step = true
如果您需要关于它的更多信息,您可以在这里的behave project中找到实现