16

How can I declare task dependencies to a TestTask ?

In this example, 'clean_database' task should be run before integration task

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
Benoît Guérout
  • 1,977
  • 3
  • 21
  • 30

2 Answers2

21

Rake enables redefining existing tasks, so this should be possible (add it to your existing code):

task :integration => :clean_database
Marek Příhoda
  • 11,108
  • 3
  • 39
  • 53
9

You can pass in the dependency to the TestTask initializer:

Rake::TestTask.new(:integration => :clean_database) do |t|
 t.libs << "test"
 t.test_files = FileList['test/**/integration/**/test*.rb']
 t.verbose = true
end
effkay
  • 898
  • 8
  • 12