Class: Test::Unit::UI::Console::TestRunner
- Inherits:
-
Object
- Object
- Test::Unit::UI::Console::TestRunner
show all
- Includes:
- Turn::Colorize
- Defined in:
- lib/turn.rb
Constant Summary
Turn::Colorize::COLORIZE, Turn::Colorize::ERROR, Turn::Colorize::FAIL, Turn::Colorize::PASS
Instance Method Summary
collapse
Instance Method Details
16
17
18
19
20
21
22
23
24
|
# File 'lib/turn.rb', line 16
def attach_to_mediator
@mediator.add_listener(TestRunnerMediator::STARTED, &method(:t_started))
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:t_finished))
@mediator.add_listener(TestCase::STARTED, &method(:t_test_started))
@mediator.add_listener(TestCase::FINISHED, &method(:t_test_finished))
@mediator.add_listener(TestResult::FAULT, &method(:t_fault))
turn_out.sync = true
@t_cur_file, @t_fault = nil
end
|
15
|
# File 'lib/turn.rb', line 15
alias :t_attach_to_mediator :attach_to_mediator
|
#t_fault(fault) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/turn.rb', line 62
def t_fault( fault )
@t_fault = true
msg = "\t"
case fault
when ::Test::Unit::Error
turn_out.puts ERROR
msg << fault.to_s.split("\n")[2..-1].join("\n\t")
when ::Test::Unit::Failure
turn_out.puts " #{FAIL}"
msg << fault.location[0].to_s << "\n\t"
msg << fault.message.gsub("\n","\n\t")
end
msg = ::ANSICode.magenta msg if COLORIZE
turn_out.puts msg
end
|
#t_finished(elapsed_time) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/turn.rb', line 30
def t_finished( elapsed_time )
failure = @t_result.failure_count
error = @t_result.error_count
total = @t_result.run_count
pass = total - failure - error
bar = '=' * 78
if COLORIZE
bar = if pass == total then ::ANSICode.green bar
else ::ANSICode.red bar end
end
turn_out.puts bar
turn_out.puts " pass: %d, fail: %d, error: %d" % [pass, failure, error]
turn_out.puts " total: %d tests with %d assertions in #{elapsed_time} seconds" % [total, @t_result.assertion_count]
turn_out.puts bar
end
|
#t_started(result) ⇒ Object
26
27
28
|
# File 'lib/turn.rb', line 26
def t_started( result )
@t_result = result
end
|
#t_test_finished(name) ⇒ Object
57
58
59
60
|
# File 'lib/turn.rb', line 57
def t_test_finished( name )
turn_out.puts " #{PASS}" unless @t_fault
@t_fault = false
end
|
#t_test_started(name) ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/turn.rb', line 48
def t_test_started( name )
method, file = name.scan(%r/^([^\(]+)\(([^\)]+)\)/o).flatten!
if @t_cur_file != file
@t_cur_file = file
turn_out.puts file
end
turn_out.print " %-69s" % method
end
|
#turn_out ⇒ Object
1.x of test/unut used @io, where as 2.x uses @output.
11
12
13
|
# File 'lib/turn.rb', line 11
def turn_out
@turn_out ||= (@io || @output)
end
|