Class: Turn::ProgressReporter

### Home Classes Methods

### In Files

- lib/turn/reporters/progress_reporter.rb

### Parent

Turn::Reporter

### Methods

- ::new
- #error
- #fail
- #finish_case
- #finish_suite
- #post_report
- #skip
- #start_case
- #start_suite

### Files

- History.txt
- LICENSE-GPL2.txt
- LICENSE-MIT.txt
- LICENSE-RUBY.txt
- LICENSE.txt
- Release.txt
- Version.txt

### Class/Module Index

Quicksearch

- Turn
- Turn::Colorize
- Turn::Command
- Turn::Configuration
- Turn::Controller
- Turn::CrossRunner
- Turn::CueReporter
- Turn::DotReporter
- Turn::IsoRunner
- Turn::MarshalReporter
- Turn::MiniRunner
- Turn::OutlineReporter
- Turn::PrettyReporter
- Turn::ProgressReporter
- Turn::Reporter
- Turn::SoloRunner
- Turn::TestCase
- Turn::TestMethod
- Turn::TestRunner
- Turn::TestSuite
- Test
- Test::Unit
- Test::Unit::Failure
- Object
- String

No matching classes.

# Turn::ProgressReporter

### Public Class Methods

new(io, opts={}) click to toggle source

    # File lib/turn/reporters/progress_reporter.rb, line 9
    def initialize(io, opts={})
      super(io, opts)
      @fails  = Hash.new{|h,k|h[k]=[]}
      @errors = Hash.new{|h,k|h[k]=[]}
      @skips  = Hash.new{|h,k|h[k]=[]}
    end

### Public Instance Methods

error(exception, message=nil) click to toggle source

    # File lib/turn/reporters/progress_reporter.rb, line 35
    def error(exception, message=nil)
      @errors[@_current_case] << exception
    end

fail(assertion, message=nil) click to toggle source

def pass(message=nil) end

    # File lib/turn/reporters/progress_reporter.rb, line 31
    def fail(assertion, message=nil)
      @fails[@_current_case] << assertion
    end

finish_case(kase) click to toggle source

    # File lib/turn/reporters/progress_reporter.rb, line 43
    def finish_case(kase)
      @pbar.inc
    end

finish_suite(suite) click to toggle source

    # File lib/turn/reporters/progress_reporter.rb, line 47
    def finish_suite(suite)
      @pbar.finish
      post_report(suite)
    end

post_report(suite) click to toggle source

    # File lib/turn/reporters/progress_reporter.rb, line 53
    def post_report(suite)
      tally = test_tally(suite)

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

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

      io.puts ("-" * (width + 60))

      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 = ("-" * (width + 60))
      tally_line << "\n%-#{width}s  " % "TOTAL"
      tally_line << "%10s %10s %10s %10s %10s" % tally

      io.puts(tally_line + "\n\n\n")

      io.puts "-- Failures --\n\n" unless @fails.empty?

      @fails.each do |tc, cc|
        cc.each do |e|
          message = e.message.tabto(0).strip
          message = Colorize.red(message)
          message += "\n" + clean_backtrace(e.backtrace).join("\n")
          io.puts(message+"\n\n")
        end
        io.puts
      end

      io.puts "-- Errors --\n\n" unless @errors.empty?

      @errors.each do |tc, cc|
        cc.each do |e|
          message = e.message.tabto(0).strip
          message = Colorize.red(message)
          message += "\n" + clean_backtrace(e.backtrace).join("\n")
          io.puts(message+"\n\n")
        end
        io.puts
      end

      #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)
      #      # backtrace ?
      #      #message += clean_backtrace(testrun.exception.backtrace).join("\n")
      #      io.puts(message+"\n\n")
      #    end
      #    io.puts
      #  end
      ##end
    end

skip(exception, message=nil) click to toggle source

    # File lib/turn/reporters/progress_reporter.rb, line 39
    def skip(exception, message=nil)
      @skips[@_current_case] << exception
    end

start_case(testcase) click to toggle source

    # File lib/turn/reporters/progress_reporter.rb, line 21
    def start_case(testcase)
      @_current_case = testcase
    end

start_suite(suite) click to toggle source

    # File lib/turn/reporters/progress_reporter.rb, line 16
    def start_suite(suite)
      @pbar = ::ANSI::Progressbar.new('Testing', suite.size)
      @pbar.inc
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.