【问题标题】:Is it possible to enhance the rake test task and merge test results together?是否可以增强 rake 测试任务并将测试结果合并在一起?
【发布时间】:2013-10-29 06:50:36
【问题描述】:

我正在为我的 sidekiq 工作人员编写测试,我希望他们在我在终端中键入“rake”时运行。我有这个工作 - 我在我的 Rakefile 中添加了以下内容:

namespace :test do
  Rake::TestTask.new(:workers) do |t|
    t.libs << "test"
    t.pattern = 'test/workers/**/*_test.rb'
  end
end

Rake::Task[:test].enhance ["test:workers"]

当我运行 rake 时,我的输出是这样的:

Run options: --seed 51172

# Running tests:

SS

Finished tests in 0.005594s, 357.5259 tests/s, 0.0000 assertions/s.

2 tests, 0 assertions, 0 failures, 0 errors, 2 skips
Run options: --seed 17561

# Running tests:

S............................................SSSS..SSSSS......

Finished tests in 2.037526s, 30.4291 tests/s, 45.6436 assertions/s.

62 tests, 93 assertions, 0 failures, 0 errors, 10 skips

S 字符是跳过 - 我还没有完成所有的测试。所以我的问题基本上是 - 有没有办法在增强后合并两组测试?我应该做一些不同于增强的事情吗?

如果我做错了什么,请告诉我,感谢您阅读本文。以防万一:Rails 4 w/Ruby 2.0

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-4 rake testunit


    【解决方案1】:

    试试这个,更改以下内容:

    Rake::TestTask.new(:workers) do |t|
    

    到这里:

    Rails::TestTask.new(:workers) do |t|
    

    这是一个小改动,但为我解决了这个问题。这意味着您的整个测试套件将使用合并的输出运行。

    【讨论】:

    • 这可能有效,也可能无效,但遗憾的是我无法确认相同的代码库,因为它是很久以前被问到的。不过,我会在下一个项目中尝试一下 - 谢谢!
    【解决方案2】:

    有一个简单的解决方法:

    bundle exec rake test:all
    

    如果你想查看 Rails 任务是如何创建的,请查看 here

    【讨论】:

      猜你喜欢
      • 2012-11-08
      • 2010-11-18
      • 1970-01-01
      • 2015-12-29
      • 1970-01-01
      • 1970-01-01
      • 2011-05-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多