【发布时间】:2013-12-17 22:50:39
【问题描述】:
如何将黄瓜场景标记为待处理,这样它就不会被算作通过?
Scenario: Guest should not see edit link
# pending implementation
难道我不能将其标记为待处理吗?
【问题讨论】:
如何将黄瓜场景标记为待处理,这样它就不会被算作通过?
Scenario: Guest should not see edit link
# pending implementation
难道我不能将其标记为待处理吗?
【问题讨论】:
我发现@wip 标记的问题在于它不会使您的测试套件变黄。它完全忽略了 wip 功能,您往往会忘记它们的存在。当场景被标记为@wip 然后被遗忘时,这让我的团队陷入了困境。我希望有更好的解决方案。我最好的方法是添加这个自定义步骤:
Given /^PENDING/ do
pending
end
与其将真正的功能标记为待处理,我可以将其与消息一起放入阵容中,如下所示:
Given PENDING: we need client input
然后它显示如下:
(::) pending steps (::)
features/example.feature:15:in `Given PENDING: we need client input'
Pending 会停止测试链,但它不会阻止 cucumber 唠叨在同一场景中遵循的任何未定义步骤。此外,理想情况下,失败和待处理的功能会告诉您失败场景的名称,但它们不会。
【讨论】:
Given(/^Pending (.*)/) do |reason| pending(reason); end。然后将场景中的第一个 Gherkin 步骤编写为 * Pending we need client input。这会将其他步骤标记为自动跳过。
好的,想通了这个。
如果在任何步骤文件中都找不到方案步骤,则将其标记为待处理。
Scenario: New product form should have some special field
Given joe is logged in as an user
When on the new exercise page
Then the select field should have some special field
将待处理的步骤存根已经足够好了。
When /^on the new exercise page$/ do
pending # express the regexp above with the code you wish you had
end
【讨论】:
另一种可能性是@wip 标签(正在进行中)。默认情况下不会运行标记为@wip 的场景,但只会在您明确请求它们时运行。
@wip
Scenario: New product form should have some special field
Given I still work on this feature
通过这种方式,您可以从自动构建中排除一些场景,以便在您处理该功能时它不会中断。
【讨论】:
除了averell的回答,你可以在运行cucumber时排除scenario标签。
如果 @todo 和 @wip 是您要用于正在进行的场景或仅标记待处理场景的标签,请运行以下功能:
cucumber --tags ~@todo --tags ~@wip
如果您使用的是Guard,请执行以下操作:
guard 'cucumber', :notification => true, :all_on_start => true,
:cmd => "bundle exec cucumber",
:cli => "--tags ~@todo --tags ~@wip" do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
Dir[File.join("**/#{m[1]}.feature")][0] || 'features'
end
end
【讨论】: