Class: TestMap::Plugins::Minitest::CacheReporter

Inherits:
Minitest::StatisticsReporter
  • Object
show all
Defined in:
lib/test_map/plugins/minitest/cache_reporter.rb

Overview

Reporter that tracks cached test count and appends it to the summary.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io = $stdout, options = {}, composite: nil) ⇒ CacheReporter

Returns a new instance of CacheReporter.



10
11
12
13
14
# File 'lib/test_map/plugins/minitest/cache_reporter.rb', line 10

def initialize(io = $stdout, options = {}, composite: nil)
  super(io, options)
  self.cached = 0
  self.composite = composite
end

Instance Attribute Details

#cached ⇒ Object

Returns the value of attribute cached.



8
9
10
# File 'lib/test_map/plugins/minitest/cache_reporter.rb', line 8

def cached
  @cached
end

#composite ⇒ Object

Returns the value of attribute composite.



8
9
10
# File 'lib/test_map/plugins/minitest/cache_reporter.rb', line 8

def composite
  @composite
end

Instance Method Details

#record(result) ⇒ Object



16
17
18
19
# File 'lib/test_map/plugins/minitest/cache_reporter.rb', line 16

def record(result)
  super
  self.cached += 1 if result.failure.is_a?(TestMap::CachedSkip)
end

#report ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/test_map/plugins/minitest/cache_reporter.rb', line 21

def report
  super
  return unless composite

  summary_reporter = composite.reporters.find { |r| r.is_a?(::Minitest::SummaryReporter) }
  return unless summary_reporter

  summary_reporter.results.reject! { |r| r.failure.is_a?(TestMap::CachedSkip) }
  summary_reporter.skips -= cached if summary_reporter.skips
  patch_summary(summary_reporter)
end