Class: Minitest::Reporters::BaseReporter

Inherits:
StatisticsReporter
  • Object
show all
Defined in:
lib/minitest/reporters/base_reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BaseReporter

Returns a new instance of BaseReporter.



6
7
8
9
# File 'lib/minitest/reporters/base_reporter.rb', line 6

def initialize(options={})
  super($stdout, options)
  self.tests = []
end

Instance Attribute Details

#tests

Returns the value of attribute tests.



4
5
6
# File 'lib/minitest/reporters/base_reporter.rb', line 4

def tests
  @tests
end

Instance Method Details

#add_defaults(defaults)



11
12
13
# File 'lib/minitest/reporters/base_reporter.rb', line 11

def add_defaults(defaults)
  self.options = defaults.merge(options)
end

#after_test(test)

called by our own after hooks



38
39
# File 'lib/minitest/reporters/base_reporter.rb', line 38

def after_test(test)
end

#before_test(test)

called by our own before hooks



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/minitest/reporters/base_reporter.rb', line 16

def before_test(test)
  last_test = tests.last

  # Minitest broke API between 5.10 and 5.11 this gets around Result object
  if last_test.respond_to? :klass
    suite_changed = last_test.klass != test.class.name
  else
    suite_changed = last_test.class != test.class
  end

  if suite_changed
    after_suite(last_test.class) if last_test
    before_suite(test.class)
  end
end

#record(test)



32
33
34
35
# File 'lib/minitest/reporters/base_reporter.rb', line 32

def record(test)
  super
  tests << test
end

#report



41
42
43
44
# File 'lib/minitest/reporters/base_reporter.rb', line 41

def report
  super
  after_suite(tests.last.class)
end