3

rspec 跳过指定测试

 3 years ago
source link: https://blog.yxwang.me/2011/11/skip-specs-by-tags/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

rspec 跳过指定测试

Sun, Nov 20, 2011 • Programming

有些测试比较耗时间,而且很少被修改,如果能在测试的时候跳过它们就能让 spec 快不少。

跳过测试的方法很简单,spec 的 describe 方法可以给对应的测试加上标签,例如

describe SalesController, :slow => true do
    # specs
end

接下来只要在 spec/spec_helper.rb 中声明跳过这个标签即可:

RSpec.configure do |config|
  config.filter_run_excluding :slow => true
end

与 filter_run_excluding 相反的是 filter_run,指定会被运行的标签,不包含在这个列表中的测试将被忽略。

参考:http://www.dixis.com/?p=283

本作品采用知识共享署名-非商业性使用 3.0 版本许可协议进行许可,欢迎转载,演绎,但是必须保留本文的署名 zellux(包含链接),且不得用于商业目的。

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK