如何跳过黄瓜步骤? [英] How to skip Cucumber steps?
问题描述
我遇到的情况是:
- 鉴于我转到此页面
- 当我键入黄瓜
- 然后单击
- 然后我应该看到文本
- 行
- Given I go to this page
- When I type cucumber
- And I click
- Then I should see the text
- And I should not see the line
如果运行此方案,它将执行所有5个步骤。但是我想跳过第四步(然后我应该看到文本)并执行第五步。
If I run this scenario it will execute all the 5 steps. But I want to skip the 4th step (Then I should see the text) and execute the 5th step.
请给我您的建议。提前致谢。 :)
Please give me your suggestions. Thanks in advance. :)
推荐答案
TL; DR-不这样做-您(可能)弄错了。而且您无法(轻松)做到这一点。正如Aslak(黄瓜的主要创建者之一)所写:
TL;DR - don't do it - you're (probably) getting it wrong. And you can't (easily) do it. As Aslak wrote (one of Cucumber main creators):
一个步骤可以得到以下结果:
A step can have the following results:
- 未定义(没有匹配的stepdef)
- 待处理(匹配的stepdef抛出PendingException)
- 通过(匹配的stepdef不会抛出任何东西)
- 失败(匹配的stepdef会抛出不是PendingException的异常)
- 已跳过(引发任何异常(未定义,挂起或失败)的步骤之后的步骤)
- undefined (no matching stepdef)
- pending (a matching stepdef that throws PendingException)
- passed (a matching stepdef that doesn't throw anything)
- failed (a matching stepdef that throws an exception that isn't PendingException)
- skipped (a step following a step that threw any exception (undefined, pending or failed))
您要的是新的一种结果-被忽略。可以通过抛出IgnoredException实现
。这意味着必须将跳过的
更改为:(在
引发任何异常(未定义,挂起或失败)的步骤之后的步骤-除非
异常为IgnoredException)
What you're asking for is a new kind of result - ignored. It could be implemented by throwing an IgnoredException. This would mean that skipped would have to be changed to: (a step following a step that threw any exception (undefined, pending or failed) - unless the exception was IgnoredException)
我不确定我是否喜欢这样。听起来好像比
还要复杂。您已经有了必要的信息,说明
出现了问题-您的步骤将失败或挂起。在继续执行以下步骤后,我看不到
的价值。您仍然必须
执行失败/挂起的步骤。
I'm not sure I like this. It sounds like more complicated than it needs to be. You already have the necessary information that something is amiss - your step will either fail or be pending. I don't see the value in continuing to execute the following steps. You still have to implement the failing/pending step.
只要您被提醒这里有工作要做,我
认为让您知道需要完成
什么样的工作会让您感到烦恼...
As long as you're reminded that "there is work to be done here" I don't think it's wortwhile complicating Cucumber to tell you what kind of work needs to be done...
Aslak
整个讨论在这里: http://comments.gmane.org/gmane.comp.programming.tools.cucumber/10146
这篇关于如何跳过黄瓜步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!