Reputation: 17900
I need to run the tests for my Rails application, but it seems that when I do rake test:all
, I get all logs outputted to my screen, including all queries performed and debug messages.
Is there a way to just show how many tests passed/failed and the failures (if any?). Something similar to what Django tests output.
Upvotes: 4
Views: 3250
Reputation: 17900
I've managed to solve this by myself.
In config/environments/test.rb
I've added the following lines:
config.logger = Logger.new(STDOUT)
config.log_level = :error
ActiveRecord::Base.logger
uses the above configuration if not stated otherwise. To customize its behavior, either set config.active_record.logger
or create a config.after_initialize
block and set ActiveRecord::Base.logger
in it.
This way, there is a centralized location for configuring the test logging level, where you can opt to output all messages or just some of them.
As a note, queries performed belong to ActiveRecord::Base.logger
, and they are logged on the :info
level. So, in order to hide them, set the log level to something higher than :info
.
Upvotes: 7