Class: Turn::Reporter

Inherits:
Object
  • Object
show all
Includes:
Colorize
Defined in:
lib/turn/reporter.rb

Overview

There are two distinct way in which a report may be utilized by a Runner: per-call or per-file. The method #pass, #fail and #error are generic, and will be used in either case. A per-call runner will use all the methods of a Reporter, while a per-file runner will use start_case per file, and will not use the start_test and finish_test methods, since those are beyond it’s grainularity.

Constant Summary

Constants included from Colorize

Colorize::COLORLESS_TERMINALS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Colorize

blue, bold, color_supported?, colorize?, #colorize?, error, fail, green, included, magenta, pass, red, skip

Constructor Details

#initialize(io, opts = {}) ⇒ Reporter

Returns a new instance of Reporter.



20
21
22
23
24
# File 'lib/turn/reporter.rb', line 20

def initialize(io, opts={})
  @io      = io || $stdout
  @trace   = opts[:trace]
  @natural = opts[:natural]
end

Instance Attribute Details

#ioObject (readonly)

Where to send report, defaults to ‘$stdout`.



18
19
20
# File 'lib/turn/reporter.rb', line 18

def io
  @io
end

Instance Method Details

#error(exception, message = nil) ⇒ Object

Invoked when a test raises an exception.



49
50
# File 'lib/turn/reporter.rb', line 49

def error(exception, message=nil)
end

#fail(assertion, message = nil) ⇒ Object

Invoked when a test raises an assertion.



45
46
# File 'lib/turn/reporter.rb', line 45

def fail(assertion, message=nil)
end

#finish_case(test_case) ⇒ Object

Invoked after all tests in a testcase have ben run.



61
62
# File 'lib/turn/reporter.rb', line 61

def finish_case(test_case)
end

#finish_suite(test_suite) ⇒ Object

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



65
66
# File 'lib/turn/reporter.rb', line 65

def finish_suite(test_suite)
end

#finish_test(test) ⇒ Object

Invoked after a test has been run.



57
58
# File 'lib/turn/reporter.rb', line 57

def finish_test(test)
end

#pass(message = nil) ⇒ Object

Invoked when a test passes.



41
42
# File 'lib/turn/reporter.rb', line 41

def pass(message=nil)
end

#skip(exception, message = nil) ⇒ Object

Invoked when a test is skipped.



53
54
# File 'lib/turn/reporter.rb', line 53

def skip(exception, message=nil)
end

#start_case(test_case) ⇒ Object

Invoked before a testcase is run.



33
34
# File 'lib/turn/reporter.rb', line 33

def start_case(test_case)
end

#start_suite(test_suite) ⇒ Object

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



29
30
# File 'lib/turn/reporter.rb', line 29

def start_suite(test_suite)
end

#start_test(test) ⇒ Object

Invoked before a test is run.



37
38
# File 'lib/turn/reporter.rb', line 37

def start_test(test)
end