如何跳过 Cucumber 步骤? [英] How to skip Cucumber steps?
问题描述
我有这样的场景:
- 鉴于我去了这个页面
- 当我输入 cucumber 时
- 然后我点击
- 那我应该看到文字了
- 我不应该看到这条线
如果我运行这个场景,它将执行所有 5 个步骤.但我想跳过第 4 步(然后我应该看到文本)并执行第 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 所写(Cucumber 的主要创造者之一):
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)
- pending(抛出 PendingException 的匹配 stepdef)
- 通过(不抛出任何东西的匹配 stepdef)
- 失败(一个匹配的 stepdef 抛出一个不是 PendingException 的异常)
- 已跳过(引发任何异常(未定义、待处理或失败)的步骤之后的步骤)
您要求的是一种新的结果 - 被忽略.它可能是通过抛出 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...
阿斯拉克
整个讨论在这里:http://comments.gmane.org/gmane.comp.Programming.tools.cucumber/10146
这篇关于如何跳过 Cucumber 步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!