即使在步骤定义失败之后,黄瓜仍会继续执行,并且它不仅输出失败的步骤,而且还会输出通过的步骤。为了确保Cucumber在遇到失败的步骤后立即停止执行,我需要使用什么选项?

这是我的cucumber.yml文件

<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
autotest: <%= std_opts %> features --color

最佳答案

使用cucumber hook

After do |s|
  # Tell Cucumber to quit after this scenario is done - if it failed.
  Cucumber.wants_to_quit = true if s.failed?
end


或者,引发异常。

推荐的方法是使用黄瓜钩。

10-05 23:39