Class: Henitai::MinitestCoverageReporter

Inherits:
Minitest::Reporter
  • Object
show all
Defined in:
lib/henitai/minitest_coverage_reporter.rb,
sig/henitai.rbs

Overview

Minitest reporter that collects per-test line coverage deltas.

Added to Minitest's reporter chain by the henitai_coverage plugin (see minitest_coverage_hook.rb). Delegates accumulation and serialisation to PerTestCoverageCollector so the JSON output format is identical to the RSpec integration.

Instance Method Summary collapse

Constructor Details

#initialize(io = $stdout, options = {}) ⇒ MinitestCoverageReporter

Returns a new instance of MinitestCoverageReporter.

Parameters:

  • (IO)
  • (Hash[untyped, untyped])


14
15
16
17
# File 'lib/henitai/minitest_coverage_reporter.rb', line 14

def initialize(io = $stdout, options = {})
  super
  @collector = PerTestCoverageCollector.new
end

Instance Method Details

#record(result) ⇒ void

This method returns an undefined value.

Parameters:

  • (Object)


19
20
21
22
23
24
25
# File 'lib/henitai/minitest_coverage_reporter.rb', line 19

def record(result)
  super
  @collector.record_test(
    relative_to_pwd(result.source_location.first),
    duration: result.time
  )
end

#relative_to_pwd(path) ⇒ String

Parameters:

  • (String)

Returns:

  • (String)


34
35
36
37
# File 'lib/henitai/minitest_coverage_reporter.rb', line 34

def relative_to_pwd(path)
  prefix = "#{Dir.pwd}#{File::SEPARATOR}"
  path.start_with?(prefix) ? path.sub(prefix, "") : path
end

#reportvoid

This method returns an undefined value.



27
28
29
30
# File 'lib/henitai/minitest_coverage_reporter.rb', line 27

def report
  super
  @collector.write_report
end