加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何确保黄瓜在步骤失败时停止执行?

发布时间:2020-12-16 20:04:18 所属栏目:百科 来源:网络整理
导读:即使在步骤定义失败之后,黄瓜仍然执行,并且不仅输出失败的步骤,还输出失败的步骤.为了确保黄瓜在遇到失败的步骤后立即停止执行,我需要使用什么选项? 这是我的cucumber.yml文件 %rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""rerun_opts = r
即使在步骤定义失败之后,黄瓜仍然执行,并且不仅输出失败的步骤,还输出失败的步骤.为了确保黄瓜在遇到失败的步骤后立即停止执行,我需要使用什么选项?

这是我的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

或者,引发例外.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读