2011-06-16 30 views
0

我被困在試圖從rake文件中調用單個單元測試方法來自動執行我的測試,但我一直收到錯誤。每次我運行'rake manage'時,在我的'管理'任務中出現錯誤:錯誤的參數數量爲0,表示爲1。這裏是我的耙文件:來自rakefile的Test :: Unit :: TestCase?

require "test_file" 
    task :default => [:commands] 

    task :manage do 
     myTest = Unit_Test.new 
     myTest.test 
    end 

而我的實際類已使用Test :: Unit :: TestCase類。這是在一個名爲'test_file.rb'的單獨文件中。

class Unit_Test < Test::Unit::TestCase 
    include Rack::Test::Methods 
    def test 
     puts "this is just a test" 
    end 
end 

有錯誤指向:

myTest = Unit_Test.new 

我如何調用這個類的單個方法?我基本上想調用這個類的某些方法來完成不同的任務,但我無法實現它的工作。我如何得到這個工作?

回答

0

你有沒有考慮過做

ruby test_file.rb --name test_method_to_be_run 

或者你需要運行多種測試方法?

此外,您使用的是哪個版本的Ruby? 1.8還是1.9?

相關問題