class Minitest::Reporters::HtmlReporter

def report

Called by the framework to generate the report
def report
  super
  begin
    puts "Writing HTML reports to #{@reports_path}"
    erb_str = File.read(@erb_template)
    renderer = ERB.new(erb_str)
    tests_by_suites = tests.group_by { |test| test_class(test) } # taken from the JUnit reporter
    suites = tests_by_suites.map do |suite, tests|
      suite_summary = summarize_suite(suite, tests)
      suite_summary[:tests] = tests.sort { |a, b| compare_tests(a, b) }
      suite_summary
    end
    suites.sort! { |a, b| compare_suites(a, b) }
    result = renderer.result(binding)
    File.open(html_file, 'w') do |f|
      f.write(result)
    end
  # rubocop:disable Lint/RescueException
  rescue Exception => e
    puts 'There was an error writing the HTML report'
    puts 'This may have been caused by cancelling the test run'
    puts 'Use mode => :verbose in the HTML reporters constructor to see more detail' if @mode == :terse
    puts 'Use mode => :terse in the HTML reporters constructor to see less detail' if @mode != :terse
    raise e if @mode != :terse
  end
  # rubocop:enable Lint/RescueException
end