I'm trying to set the logging level for the tests I'm running in test/unit
require 'test/unit'
require 'logger'
class MyMath
def self.adder(a,b)
a+b
end
end
class Tester < Test::Unit::TestCase
$logger = Logger.new($stdout)
def test_adder()
$logger.info "Starting Test"
assert_equal(4, MyMath.adder(2,2) )
$logger.info "Ending Test"
end
end
And the output is
Loaded suite ruby.test
Started
I, [2021-07-23T13:12:26.497311 #49542] INFO -- : Starting Test
I, [2021-07-23T13:12:26.497375 #49542] INFO -- : Ending Test
.
Finished in 0.000358 seconds.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
2793.30 tests/s, 2793.30 assertions/s
How do I get it to NOT print the logging messages? In the Test::Unit::UI::Console::TestRunner code it talks about
# Creates a new TestRunner for running the passed
# suite. If quiet_mode is true, the output while
# running is limited to progress dots, errors and
# failures, and the final result. io specifies
# where runner output should go to; defaults to
# STDOUT.
What is quiet_mode, and how can I set it?
I think your problem is that you need to set the log level of your logger accordingly.
https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html
Not sure if you use any framework so you could just set the log level in test like