如何向 TestTask 声明任务依赖项?
在此示例中,“clean_database”任务应在集成任务之前运行
Rake::TestTask.new(:integration) do |t|
t.libs << "test"
t.test_files = FileList['test/**/integration/**/test*.rb']
t.verbose = true
end
task :clean_database => [:init] do
#...
end
Rake 可以重新定义现有任务,因此这应该是可能的(将其添加到现有代码中):
task :integration => :clean_database
您可以将依赖项传递给 TestTask 初始化程序:
Rake::TestTask.new(:integration => :clean_database) do |t|
t.libs << "test"
t.test_files = FileList['test/**/integration/**/test*.rb']
t.verbose = true
end