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

ruby-on-rails – 如何一次运行多个Rails单元测试

发布时间:2020-12-16 20:19:36 所属栏目:百科 来源:网络整理
导读:我经常运行各种测试组,如: rake test:unitsrake test:functionals 我也喜欢运行单独的测试文件或单独的测试: ruby -Itest test/unit/file_test.rbruby -Itest test/unit/file_test.rb -n '/some context Im working on/' 还有: rake test TEST=test/unit/
我经常运行各种测试组,如:
rake test:units
rake test:functionals

我也喜欢运行单独的测试文件或单独的测试:

ruby -Itest test/unit/file_test.rb
ruby -Itest test/unit/file_test.rb -n '/some context Im working on/'

还有:

rake test TEST=test/unit/file_test.rb

我甚至在我的Rakefile中创建了自定义分组:

Rake::TestTask.new(:ps3) do |t|
    t.libs << 'test'
    t.verbose = true
    t.test_files = FileList["test/unit/**/ps3_*_test.rb","test/functional/services/ps3/*_test.rb"]
  end

我还没有想到的是如何在命令行中运行多个临时性测试.换句话说,我如何将test_files注入耙子任务.就像是:

rake test TEST=test/unit/file_test.rb,test/functional/files_controller_test.rb

然后我可以运行一个shell函数,使用任意参数,运行快速ruby -Itest单个测试,或者如果有多个文件,则可以运行rake任务.

解决方法

bundle exec ruby?? -I.:test -e“ARGV.each {| f | require f}”file1 file1

要么:

找到test -name’* _test.rb’| xargs -t bundle exec ruby?? -I.:test -e“ARGV.each {| f | require f}”

(编辑:李大同)

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

    推荐文章
      热点阅读