Parent

Turn::PrettyReporter

Pretty Reporter (by Paydro)

Example output:

TestCaseName:
     PASS test: Succesful test case.  (0:00:02:059)
    ERROR test: Bogus test case.  (0:00:02:059)
     FAIL test: Failed test case.  (0:00:02:059)

Constants

TAB_SIZE

Second column left padding in chars.

TRACE_MARK

Character to put in front of backtrace.

Public Instance Methods

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

Invoked when a test raises an exception.

# File lib/turn/reporters/pretty_reporter.rb, line 69
def error(exception, message=nil)
  banner ERROR

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

Invoked when a test raises an assertion.

# File lib/turn/reporters/pretty_reporter.rb, line 62
def fail(assertion, message=nil)
  banner FAIL

  prettify(assertion, message)
end
finish_case(kase) click to toggle source

Invoked after all tests in a testcase have ben run.

# File lib/turn/reporters/pretty_reporter.rb, line 83
def finish_case(kase)
  # Print newline is there any tests in suite
  io.puts if kase.size > 0
end
finish_suite(suite) click to toggle source

After all tests are run, this is the last observable action.

# File lib/turn/reporters/pretty_reporter.rb, line 89
def finish_suite(suite)
  total      = colorize_count("%d tests", suite.count_tests, :bold)
  passes     = colorize_count("%d passed", suite.count_passes, :pass)
  assertions = colorize_count("%d assertions", suite.count_assertions, nil)
  failures   = colorize_count("%d failures", suite.count_failures, :fail)
  errors     = colorize_count("%d errors", suite.count_errors, :error)
  skips      = colorize_count("%d skips", suite.count_skips, :skip)

  io.puts "Finished in %.6f seconds." % (Time.now - @time)
  io.puts

  io.puts [ total, passes, failures, errors, skips, assertions ].join(", ")

  # Please keep this newline, since it will be useful when after test case
  # there will be other lines. For example "rake aborted!" or kind of.
  io.puts
end
pass(message=nil) click to toggle source

Invoked when a test passes.

# File lib/turn/reporters/pretty_reporter.rb, line 50
def pass(message=nil)
  banner PASS

  if message
    message = Colorize.magenta(message)
    message = message.to_s.tabto(TAB_SIZE)

    io.puts(message)
  end
end
skip(exception, message=nil) click to toggle source

Invoked when a test is skipped.

# File lib/turn/reporters/pretty_reporter.rb, line 76
def skip(exception, message=nil)
  banner SKIP

  prettify(exception, message)
end
start_case(kase) click to toggle source

Invoked before a testcase is run.

# File lib/turn/reporters/pretty_reporter.rb, line 37
def start_case(kase)
  # Print case name if there any tests in suite
  # TODO: Add option which will show all test cases, even without tests?
  io.puts kase.name if kase.size > 0
end
start_suite(suite) click to toggle source

At the very start, before any testcases are run, this is called.

# File lib/turn/reporters/pretty_reporter.rb, line 22
def start_suite(suite)
  @suite  = suite
  @time   = Time.now

  io.puts Colorize.bold("Loaded Suite #{suite.name}")
  io.puts
  if suite.seed
    io.puts "Started at #{Time.now} w/ seed #{suite.seed}."
  else
    io.puts "Started at #{Time.now}."
  end
  io.puts
end
start_test(test) click to toggle source

Invoked before a test is run.

# File lib/turn/reporters/pretty_reporter.rb, line 44
def start_test(test)
  @test_time = Time.now
  @test = test
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.