lib/turn/reporters/dot_reporter.rb in turn-0.7.0 vs lib/turn/reporters/dot_reporter.rb in turn-0.8.0
- old
+ new
@@ -17,49 +17,64 @@
def start_test(test)
end
def pass(message=nil)
- io.print '.'; io.flush
+ io.print Colorize.pass('.'); io.flush
end
def fail(message=nil)
- io.print 'F'; io.flush
+ io.print Colorize.fail('F'); io.flush
end
def error(message=nil)
- io.print 'E'; io.flush
+ io.print Colorize.error('E'); io.flush
end
def finish_test(test)
end
def finish_case(kase)
end
def finish_suite(suite)
io.puts("\nFinished in %.5f seconds." % [Time.now - @time])
- io.puts
report = ''
- fails = suite.select do |testrun|
- testrun.fail? || testrun.error?
+ list = []
+ suite.each do |testcase|
+ testcase.each do |testunit|
+ if testunit.fail? || testunit.error?
+ list << testunit
+ end
+ end
end
- unless fails.empty? # or verbose?
+ unless list.empty? # or verbose?
#report << "\n\n-- Failures and Errors --\n\n"
- fails.uniq.each do |testrun|
- message = testrun.message.tabto(0)
- message = ::ANSICode.magenta(message) if COLORIZE
- report << message << "\n"
+ list.uniq.each do |testunit|
+ message = testunit.fail? ? ' '+FAIL : ERROR
+ message = message + ' ' + testunit.message.tabto(0)
+ message << "\n" + filter_backtrace(testunit.backtrace).first
+ report << "\n" << message << "\n"
end
report << "\n"
end
io.puts report
- io.puts "%s tests, %s assetions, %s failures, %s errors" % test_tally(suite)
+ count = test_tally(suite)
+
+ tally = "%s tests, %s assertions, %s failures, %s errors" % count
+
+ if count[-1] > 0 or count[-2] > 0
+ tally = Colorize.red(tally)
+ else
+ tally = Colorize.green(tally)
+ end
+
+ io.puts tally
end
private
def test_tally(suite)