Class: Minitest::Queue::TestTimeReporter

Inherits:
Reporters::BaseReporter
  • Object
show all
Includes:
CI::Queue::OutputHelpers
Defined in:
lib/minitest/queue/test_time_reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(build:, limit: nil, percentile: nil, **options) ⇒ TestTimeReporter

Returns a new instance of TestTimeReporter.



9
10
11
12
13
14
15
# File 'lib/minitest/queue/test_time_reporter.rb', line 9

def initialize(build:, limit: nil, percentile: nil, **options)
  super(options)
  @test_time_hash = build.fetch
  @limit = limit
  @percentile = percentile
  @success = true
end

Instance Method Details

#recordObject

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/minitest/queue/test_time_reporter.rb', line 42

def record(*)
  raise NotImplementedError
end

#reportObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/minitest/queue/test_time_reporter.rb', line 17

def report
  return if limit.nil? || test_time_hash.empty?

  puts '+++ Test Time Report'

  if offending_tests.empty?
    msg = "The #{humanized_percentile} of test execution time is within #{limit} milliseconds."
    puts green(msg)
    return
  end

  @success = false
  puts "    \#{red(\"Detected \#{offending_tests.size} test(s) over the desired time limit.\")}\n    Please make them faster than \#{limit}ms in the \#{humanized_percentile} percentile.\n  EOS\n  offending_tests.each do |test_name, duration|\n    puts \"\#{red(test_name)}: \#{duration}ms\"\n  end\nend\n"

#success?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/minitest/queue/test_time_reporter.rb', line 38

def success?
  @success
end