class Minitest::Heat::Map
Constants
- WEIGHTS
So we can sort hot spots by liklihood of being the most important spot to check out before
trying to fix something. These are ranked based on the possibility they represent ripple effects where fixing one problem could potentially fix multiple other failures. For example, if there's an exception in the file, start there. Broken code can't run. If a test is broken (i.e. raising an exception), that's a special sort of failure that would be misleading. It doesn't represent a proper failure, but rather a test that doesn't work.
Attributes
hits[R]
Public Class Methods
new()
click to toggle source
# File lib/minitest/heat/map.rb, line 24 def initialize @hits = {} end
Public Instance Methods
add(filename, line_number, type)
click to toggle source
# File lib/minitest/heat/map.rb, line 28 def add(filename, line_number, type) @hits[filename] ||= { weight: 0, total: 0 } @hits[filename][:total] += 1 @hits[filename][:weight] += WEIGHTS[type] @hits[filename][type] ||= [] @hits[filename][type] << line_number end
files()
click to toggle source
# File lib/minitest/heat/map.rb, line 37 def files hot_files .sort_by { |filename, weight| weight } .reverse .take(5) end
Private Instance Methods
hot_files()
click to toggle source
# File lib/minitest/heat/map.rb, line 46 def hot_files files = {} @hits.each_pair do |filename, details| # Can't really be a "hot spot" with just a single issue # next unless details[:weight] > 1 files[filename] = details[:weight] end files end