Ruby 来自rakefile的Test::Unit::TestCase?
我一直试图从一个rake文件中调用单个单元测试方法来自动化测试,但我总是遇到一个错误。每次运行“rake manage”时,我的“manage”任务中都会出现一个错误,即:错误数量的参数0代表1。这是我的rake文件:Ruby 来自rakefile的Test::Unit::TestCase?,ruby,unit-testing,rake,testunit,Ruby,Unit Testing,Rake,Testunit,我一直试图从一个rake文件中调用单个单元测试方法来自动化测试,但我总是遇到一个错误。每次运行“rake manage”时,我的“manage”任务中都会出现一个错误,即:错误数量的参数0代表1。这是我的rake文件: require "test_file" task :default => [:commands] task :manage do myTest = Unit_Test.new myTest.test end
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
如何从这个类中调用单个方法?我基本上想在不同的任务中调用这个类中的某些方法,但我无法让它工作。我怎样才能让它工作呢?你考虑过这样做吗
ruby test_file.rb --name test_method_to_be_run
或者您需要运行多种测试方法吗
另外,您使用的是什么版本的Ruby?1.8还是1.9
ruby test_file.rb --name test_method_to_be_run