【问题标题】:running rake task运行 rake 任务
【发布时间】:2010-10-06 04:48:36
【问题描述】:

为什么当我运行任务时:

my_project> rake  import:twitter

Task.path:lib/task/import_twitter.rake

namespace :import do
   task :twitter => :environment do
     puts "importing...."
   end
end

那么测试也运行?

在控制台输出中:

    importing....
    Loaded suite C:/Ruby/bin/rake
    Started


    Finished in 0.001 seconds.

    0 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifica
    tions
    0% passed

任务执行时如何不运行测试?

【问题讨论】:

  • 你的 Rakefile 和你的 rask 文件任务怎么样?

标签: ruby-on-rails rake rake-task


【解决方案1】:

您好,您可以编写您的任务,然后编写新的任务,该任务将调用两个单独的任务 - 运行测试和您的类似 task :run_all => ['db:test:clone ', 'db:test:prepare ', 'test:units', :your_task]

【讨论】:

    【解决方案2】:

    没有执行任何测试(计数始终为 0)。

    如果您加载test/unit,您始终会获得测试统计信息。只需尝试以下文件:

    require 'test/unit'
    

    如果你在任何地方加载test/unit,你能检查你的 rakefile 吗? (也许它在所需文件之一中)您可以检查$" 是否包含test/unit

    背景: test-unit 启动at_exit(脚本结束)一些例程,并在 Test::Unit::TestCase 的子项中查找测试方法并执行它们。在此之后,将写入统计信息。如果没有测试,您将获得“空”测试统计信息。

    【讨论】:

      猜你喜欢
      • 2010-10-09
      • 2012-11-15
      • 2014-12-05
      • 1970-01-01
      • 2019-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-30
      相关资源
      最近更新 更多