In my rake task if I want to know the开发者_运维知识库 name of the file when that file is picked up for testing then how do I do that. Reason is that some of the files produce warning. I am not sure which of my 800 tests is producing warning.
My rake task is something like this. I am using rails3.
Rake::TestTask.new(:test_hr_module) do |t|
t.libs << 'test'
t.test_files = Dir.glob('test/{hr}/**/*_test.rb').sort
t.warning = true
t.verbose = true
end
You can always call single files:
ruby test/unit/model_test.rb
You can even use the name flag to only run specific tests
ruby test/unit/model_test.rb -n test_name
You'll probably need to change require 'test_helper'
to require 'test/test_helper'
in the test file though.
If you really need to do this in a rake task could you try:
Dir.glob('test/**/*_test.rb').each do |f|
puts `ruby #{f}`
end
end
Perhaps you can use the pseudo-variable __FILE__
to achieve this?
精彩评论