Class: Turn::ProgressReporter

Inherits:
Reporter
  • Object
show all
Defined in:
lib/turn/reporters/progress_reporter.rb

Constant Summary

Constants included from Colorize

Colorize::COLORIZE, Colorize::ERROR, Colorize::FAIL, Colorize::PASS, Colorize::SKIP

Instance Attribute Summary

Attributes inherited from Reporter

#io

Instance Method Summary collapse

Methods inherited from Reporter

#error, #fail, #finish_test, #initialize, #pass, #start_case, #start_test

Methods included from Colorize

blue, bold, error, fail, green, magenta, pass, red, skip

Constructor Details

This class inherits a constructor from Turn::Reporter

Instance Method Details

#finish_case(kase) ⇒ Object

def error(message=nil)

#@pbar.inc

end



32
33
34
# File 'lib/turn/reporters/progress_reporter.rb', line 32

def finish_case(kase)
  @pbar.inc
end

#finish_suite(suite) ⇒ Object



36
37
38
39
# File 'lib/turn/reporters/progress_reporter.rb', line 36

def finish_suite(suite)
  @pbar.finish
  post_report(suite)
end

#post_report(suite) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/turn/reporters/progress_reporter.rb', line 42

def post_report(suite)
  tally = test_tally(suite)

  width = suite.collect{ |tr| tr.name.size }.max

  headers = [ 'TESTCASE  ', '  TESTS   ', 'ASSERTIONS', ' FAILURES ', '  ERRORS   ' ]
  io.puts "\n%-#{width}s       %10s %10s %10s %10s\n" % headers

  files = nil

  suite.each do |testrun|
    if testrun.files != [testrun.name] && testrun.files != files
      label = testrun.files.join(' ')
      label = Colorize.magenta(label)
      io.puts(label + "\n")
      files = testrun.files
    end
    io.puts paint_line(testrun, width)
  end

  #puts("\n%i tests, %i assertions, %i failures, %i errors\n\n" % tally)

  tally_line = "-----\n"
  tally_line << "%-#{width}s  " % "TOTAL"
  tally_line << "%10s %10s %10s %10s" % tally

  io.puts(tally_line + "\n")

  fails = suite.select do |testrun|
    testrun.fail? || testrun.error?
  end

  #if tally[2] != 0 or tally[3] != 0
    unless fails.empty? # or verbose?
      io.puts "\n\n-- Failures and Errors --\n\n"
      fails.uniq.each do |testrun|
        message = testrun.message.tabto(0).strip
        message = Colorize.red(message)
        io.puts(message+"\n\n")
      end
      io.puts
    end
  #end
end

#start_suite(suite) ⇒ Object



9
10
11
12
# File 'lib/turn/reporters/progress_reporter.rb', line 9

def start_suite(suite)
  @pbar = ::ANSI::Progressbar.new('Testing', suite.size)
  @pbar.inc
end