Class: Minitest::TestProf::TagProfReporter

Inherits:
BaseReporter
  • Object
show all
Defined in:
lib/test_prof/tag_prof/minitest.rb

Overview

:nodoc:

Constant Summary

Constants included from TestProf::Logging

TestProf::Logging::COLORS

Instance Attribute Summary collapse

Attributes inherited from BaseReporter

#io

Instance Method Summary collapse

Methods inherited from BaseReporter

#after_test, #before_test, #start

Methods included from TestProf::Logging

#log

Constructor Details

#initialize(io = $stdout, _options = {}) ⇒ TagProfReporter

Returns a new instance of TagProfReporter.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/test_prof/tag_prof/minitest.rb', line 8

def initialize(io = $stdout, _options = {})
  super
  @results = ::TestProf::TagProf::Result.new("type")

  if event_prof_activated?
    require "test_prof/event_prof"
    @current_group_id = nil
    @events_profiler = configure_profiler
    @results = ::TestProf::TagProf::Result.new("type", @events_profiler.events)
  end
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



6
7
8
# File 'lib/test_prof/tag_prof/minitest.rb', line 6

def results
  @results
end

Instance Method Details

#prerecord(group, example) ⇒ Object



20
21
22
23
24
25
# File 'lib/test_prof/tag_prof/minitest.rb', line 20

def prerecord(group, example)
  return unless event_prof_activated?

  # enable event profiling
  @events_profiler.group_started(true)
end

#record(result) ⇒ Object



27
28
29
30
# File 'lib/test_prof/tag_prof/minitest.rb', line 27

def record(result)
  results.track(main_folder_path(result), time: result.time, events: fetch_events_data)
  @events_profiler.group_started(nil) if event_prof_activated? # reset and disable event profilers
end

#reportObject



32
33
34
35
# File 'lib/test_prof/tag_prof/minitest.rb', line 32

def report
  printer = (ENV["TAG_PROF_FORMAT"] == "html") ? ::TestProf::TagProf::Printers::HTML : ::TestProf::TagProf::Printers::Simple
  printer.dump(results)
end