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, mark, pass, red, skip

Constructor Details

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

Returns a new instance of Reporter.



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

def initialize(io, opts={})
  @io      = io || $stdout
  @trace   = opts[:trace]
  @natural = opts[:natural]
  @verbose = opts[:verbose]
  @mark    = opts[:mark].to_i
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.



51
52
# File 'lib/turn/reporter.rb', line 51

def error(exception, message=nil)
end

#fail(assertion, message = nil) ⇒ Object

Invoked when a test raises an assertion.



47
48
# File 'lib/turn/reporter.rb', line 47

def fail(assertion, message=nil)
end

#finish_case(test_case) ⇒ Object

Invoked after all tests in a testcase have ben run.



63
64
# File 'lib/turn/reporter.rb', line 63

def finish_case(test_case)
end

#finish_suite(test_suite) ⇒ Object

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



67
68
# File 'lib/turn/reporter.rb', line 67

def finish_suite(test_suite)
end

#finish_test(test) ⇒ Object

Invoked after a test has been run.



59
60
# File 'lib/turn/reporter.rb', line 59

def finish_test(test)
end

#pass(message = nil) ⇒ Object

Invoked when a test passes.



43
44
# File 'lib/turn/reporter.rb', line 43

def pass(message=nil)
end

#skip(exception, message = nil) ⇒ Object

Invoked when a test is skipped.



55
56
# File 'lib/turn/reporter.rb', line 55

def skip(exception, message=nil)
end

#start_case(test_case) ⇒ Object

Invoked before a testcase is run.



35
36
# File 'lib/turn/reporter.rb', line 35

def start_case(test_case)
end

#start_suite(test_suite) ⇒ Object

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



31
32
# File 'lib/turn/reporter.rb', line 31

def start_suite(test_suite)
end

#start_test(test) ⇒ Object

Invoked before a test is run.



39
40
# File 'lib/turn/reporter.rb', line 39

def start_test(test)
end