Tips – Print test name and file name when testing (Final Solution)
As previous solution doesn’t works, after read source code of ActiveSupport::TestCase I find a final solution.
setup :log_test
private
def log_test
unless @already_logged_this_test
puts "\n\nStarting #{@method_name} in class:#{self.class.name}\n#{'-' * (20 + @method_name.length + self.class.name.length)}\n"
end
@already_logged_this_test = true
end
setup is a callback of ActiveSupport::TestCase. So we doesn’t hack anything. It works fine.
And what’s more rake test already support verbose model
if you using run test directly like this, TESTOPTS="-v" doesn’t work






