2015-06-13 05:56:32 -04:00
|
|
|
require "active_support/core_ext/class/attribute"
|
2015-01-23 16:05:31 -05:00
|
|
|
require "minitest"
|
|
|
|
|
|
|
|
module Rails
|
|
|
|
class TestUnitReporter < Minitest::StatisticsReporter
|
2015-06-13 05:56:32 -04:00
|
|
|
class_attribute :executable
|
|
|
|
self.executable = "bin/rails test"
|
|
|
|
|
2015-01-23 16:05:31 -05:00
|
|
|
def report
|
2015-02-03 21:54:50 -05:00
|
|
|
return if results.empty?
|
2015-01-23 16:05:31 -05:00
|
|
|
io.puts
|
2015-01-24 05:48:17 -05:00
|
|
|
io.puts "Failed tests:"
|
2015-01-23 16:05:31 -05:00
|
|
|
io.puts
|
|
|
|
io.puts aggregated_results
|
|
|
|
end
|
|
|
|
|
|
|
|
def aggregated_results # :nodoc:
|
|
|
|
filtered_results = results.dup
|
|
|
|
filtered_results.reject!(&:skipped?) unless options[:verbose]
|
|
|
|
filtered_results.map do |result|
|
2015-01-23 22:57:52 -05:00
|
|
|
location, line = result.method(result.name).source_location
|
2015-06-13 05:56:32 -04:00
|
|
|
"#{self.executable} #{relative_path_for(location)}:#{line}"
|
2015-01-23 22:57:52 -05:00
|
|
|
end.join "\n"
|
2015-01-23 16:05:31 -05:00
|
|
|
end
|
2015-03-21 08:15:56 -04:00
|
|
|
|
|
|
|
def relative_path_for(file)
|
|
|
|
file.sub(/^#{Rails.root}\/?/, '')
|
|
|
|
end
|
2015-01-23 16:05:31 -05:00
|
|
|
end
|
|
|
|
end
|