class Minitest::HeatReporter
Custom minitest reporter to proactively identify likely culprits in test failures by focusing on
the files and line numbers with the most issues and that were most recently modified. It also visually emphasizes results based on the most significant problems. 1. Errors - Anything that raised an exception could have significant ripple effects. 2. Failures - Assuming no exceptions, these are kind of important. -- Everything else... 3. Coverage (If using Simplecov) - If things are passing but coverage isn't up to par 4. Skips - Don't want to skip tests. 5. Slows (If everything good, but there's )
-
Colorize the Output
-
What files had the most errors?
-
Show the most impacted areas first.
-
Show lowest-level (most nested code) frist.
Pulls from existing reporters:
https://github.com/seattlerb/minitest/blob/master/lib/minitest.rb#L554
Lots of insight from:
http://www.monkeyandcrow.com/blog/reading_ruby_minitest_plugin_system/
And a good example available at:
https://github.com/adamsanderson/minitest-snail
Pulls from minitest-color as well:
https://github.com/teoljungberg/minitest-color/blob/master/lib/minitest/color_plugin.rb
Attributes
map[R]
options[R]
output[R]
results[R]
Public Class Methods
new(io = $stdout, options = {})
click to toggle source
# File lib/minitest/heat_reporter.rb, line 38 def initialize(io = $stdout, options = {}) @output = Heat::Output.new(io) @options = options @results = Heat::Results.new @map = Heat::Map.new end
Public Instance Methods
passed?()
click to toggle source
Did this run pass?
# File lib/minitest/heat_reporter.rb, line 98 def passed? results.errors.empty? && results.failures.empty? end
prerecord(klass, name)
click to toggle source
About to start running a test. This allows a reporter to show that it is starting or that we are in the middle of a test run.
# File lib/minitest/heat_reporter.rb, line 55 def prerecord(klass, name) end
record(result)
click to toggle source
Records the data from a result. Minitest::Result source:
https://github.com/seattlerb/minitest/blob/f4f57afaeb3a11bd0b86ab0757704cb78db96cf4/lib/minitest.rb#L504
# File lib/minitest/heat_reporter.rb, line 61 def record(result) issue = Heat::Issue.new(result) @results.record(issue) @map.add(*issue.to_hit) if issue.hit? output.marker(issue.marker) end
report()
click to toggle source
Outputs the summary of the run.
# File lib/minitest/heat_reporter.rb, line 71 def report @results.stop_timer! output.newline output.newline # Issues start with the least critical and go up to the most critical so that the most # pressing issues are displayed at the bottom of the report in order to reduce scrolling. # This way, as you fix issues, the list gets shorter, and eventually the least critical # issues will be displayed without scrolling once more problematic issues are resolved. if results.failures.empty? && results.brokens.empty? && results.errors.empty? && results.skips.empty? results.slows.each { |issue| output.issue_details(issue) } end if results.failures.empty? && results.brokens.empty? && results.errors.empty? results.skips.each { |issue| output.issue_details(issue) } end results.failures.each { |issue| output.issue_details(issue) } results.brokens.each { |issue| output.issue_details(issue) } results.errors.each { |issue| output.issue_details(issue) } output.compact_summary(results) output.heat_map(map) end
start()
click to toggle source
Starts reporting on the run.
# File lib/minitest/heat_reporter.rb, line 47 def start output.puts output.puts @results.start_timer! end