Selenium Behave Python,如果失败,如何将场景设置为跳过或未测试

发布于 2025-01-13 04:29:29 字数 764 浏览 0 评论 0原文

使用 Selenium Behave Python,

如果某个步骤失败,是否可以强制将场景状态重置为已跳过或未经测试?

我知道我可以使用 @Skip 标签跳过一个场景,但我需要运行该场景并检查,如果一个步骤失败,我希望在报告中显示此场景已被跳过或未经测试或其他内容,但不是失败或通过。

example:
Feature test
 Scenario: test something
        Given the situation A
        When the user presses the button
        Then the page show something
        And something else should happen
 
@then('the page show something')
  def step_page_show_something(context):
      try:
         do something
         #here the step can fail
      except:
          # if I use 'pass' the test will be Pass
          # if I use an exception if will Failed
          # there is any way to skip or set it as Untested or something else but not Failed and not Passed

感谢您的所有提示。

with Selenium Behave Python,

Is possible to force and reset the status of a scenario as skipped or untested if a step on it fails?

I know I can skip a scenario with @Skip tag, but I need to run the scenario and check, if one step fails I would like to have in the report that this scenario is skipped or Untested or something else but not as Failed or Passed.

example:
Feature test
 Scenario: test something
        Given the situation A
        When the user presses the button
        Then the page show something
        And something else should happen
 
@then('the page show something')
  def step_page_show_something(context):
      try:
         do something
         #here the step can fail
      except:
          # if I use 'pass' the test will be Pass
          # if I use an exception if will Failed
          # there is any way to skip or set it as Untested or something else but not Failed and not Passed

Thanks for all the tips.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

無處可尋 2025-01-20 04:29:29

我找到的唯一解决方案正是在帖子 Skip a Bee step in步骤实施

在我的

def step_page_show_something(context):
      try:
         do something
         #here the step can fail
      except:
         context.scenario.skip()

The only solution that I found was exactly in the post Skip a behave step in the step implementation

On my

def step_page_show_something(context):
      try:
         do something
         #here the step can fail
      except:
         context.scenario.skip()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文