RSpec 异常后继续
有没有办法让 RSpec 在引发异常后继续处理规范?
这就是我的规范任务的样子:
SPEC_PATTERN = "spec/**/*_spec.rb"
Spec::Rake::SpecTask.new() do |t|
t.spec_files = FileList[SPEC_PATTERN]
t.verbose = true
t.spec_opts = ["--format", "html:spec/spec_report.html"]
t.fail_on_error = false
t.rcov = true
t.rcov_dir = 'coverage'
t.rcov_opts = ['--exclude', 'spec']
end
Is there any way to have RSpec continue processing specifications after an exception is raised?
This is what my spec task looks like:
SPEC_PATTERN = "spec/**/*_spec.rb"
Spec::Rake::SpecTask.new() do |t|
t.spec_files = FileList[SPEC_PATTERN]
t.verbose = true
t.spec_opts = ["--format", "html:spec/spec_report.html"]
t.fail_on_error = false
t.rcov = true
t.rcov_dir = 'coverage'
t.rcov_opts = ['--exclude', 'spec']
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用“should raise_exception”怎么样?
http://rspec.rubyforge.org/rspec/ 1.3.0/classes/Spec/Matchers.html#M000183
what about using "should raise_exception"?
http://rspec.rubyforge.org/rspec/1.3.0/classes/Spec/Matchers.html#M000183
rspec 确实捕获异常并将其报告为失败,与 test/unit 的方式大致相同。如果您看到任务退出,那是因为异常要么在 rspec 正在处理的代码之外,要么可能是语法错误。
哈特哈,
大卫
rspec does capture exceptions and report them as failures, in much the same way test/unit does. If you're seeing the task exiting it's because the exception is either outside of the code that rspec is handling, or it might be a syntax error.
HTH,
David