Module: Minitest
- Defined in:
- lib/minitest/reporter_api.rb
Constant Summary collapse
- DEFAULT_REPORTER =
[SummaryReporter, ProgressReporter]
Class Method Summary collapse
-
.default_reporter(options) ⇒ Object
Create default composite reporter.
-
.run(args = []) ⇒ Object
Modify Minitest’s run method to check for code configured reporters.
Class Method Details
.default_reporter(options) ⇒ Object
Create default composite reporter.
Unfortunately some reporters take no arguments, some take just ‘options` and others take `io` and `options`, so the arity is used to determine which arguments to use.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/minitest/reporter_api.rb', line 50 def self.default_reporter() reporter = CompositeReporter.new defaults = [self.reporter || DEFAULT_REPORTER].flatten defaults.each do |rpt| reporter << ( case rpt when Class case rpt.method(:new).arity when 0 then rpt.new when 1, -1 then rpt.new() else rpt.new([:io], ) end else rpt end ) end reporter end |
.run(args = []) ⇒ Object
Modify Minitest’s run method to check for code configured reporters. This allows reporters to be configured in test helper scripts. e.g.
Minitest.reporter = MyReporter.new
If just the class is given, it will work as well.
Minitest.reporter = MyReporter
More than one reporter can be used by setting reporter to an array.
Minitest.reporter = [Minitest::SummaryReporter, MyReporter.new]
This definition is identical to Minitest’s with the exception of the ‘if self.reporter` condition.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/minitest/reporter_api.rb', line 24 def self.run args = [] self.load_plugins = process_args args reporter = default_reporter() self.reporter = reporter # this makes it available to plugins self.init_plugins self.reporter = nil # runnables shouldn't depend on the reporter, ever reporter.start __run reporter, self.parallel_executor.shutdown rescue nil reporter.report reporter.passed? end |