Class Test::Unit::UI::Console::TestRunner
In: lib/test/unit/ui/console/testrunner.rb
Parent: Object

Runs a Test::Unit::TestSuite on the console.

Methods

Public Class methods

Creates a new TestRunner for running the passed suite. If quiet_mode is true, the output while running is limited to progress dots, errors and failures, and the final result. io specifies where runner output should go to; defaults to STDOUT.

[Source]

    # File lib/test/unit/ui/console/testrunner.rb, line 25
25:           def initialize(suite, output_level=NORMAL, io=STDOUT)
26:             if (suite.respond_to?(:suite))
27:               @suite = suite.suite
28:             else
29:               @suite = suite
30:             end
31:             @output_level = output_level
32:             @io = io
33:             @already_outputted = false
34:             @faults = []
35:           end

Public Instance methods

Begins the test run.

[Source]

    # File lib/test/unit/ui/console/testrunner.rb, line 38
38:           def start
39:             setup_mediator
40:             attach_to_mediator
41:             return start_mediator
42:           end

Private Instance methods

[Source]

    # File lib/test/unit/ui/console/testrunner.rb, line 70
70:           def add_fault(fault)
71:             @faults << fault
72:             output_single(fault.single_character_display, PROGRESS_ONLY)
73:             @already_outputted = true
74:           end

[Source]

    # File lib/test/unit/ui/console/testrunner.rb, line 58
58:           def attach_to_mediator
59:             @mediator.add_listener(TestResult::FAULT, &method(:add_fault))
60:             @mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
61:             @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
62:             @mediator.add_listener(TestCase::STARTED, &method(:test_started))
63:             @mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
64:           end

[Source]

    # File lib/test/unit/ui/console/testrunner.rb, line 54
54:           def create_mediator(suite)
55:             return TestRunnerMediator.new(suite)
56:           end

[Source]

    # File lib/test/unit/ui/console/testrunner.rb, line 81
81:           def finished(elapsed_time)
82:             nl
83:             output("Finished in #{elapsed_time} seconds.")
84:             @faults.each_with_index do |fault, index|
85:               nl
86:               output("%3d) %s" % [index + 1, fault.long_display])
87:             end
88:             nl
89:             output(@result)
90:           end

[Source]

     # File lib/test/unit/ui/console/testrunner.rb, line 102
102:           def nl(level=NORMAL)
103:             output("", level)
104:           end

[Source]

     # File lib/test/unit/ui/console/testrunner.rb, line 106
106:           def output(something, level=NORMAL)
107:             @io.puts(something) if (output?(level))
108:             @io.flush
109:           end

[Source]

     # File lib/test/unit/ui/console/testrunner.rb, line 116
116:           def output?(level)
117:             level <= @output_level
118:           end

[Source]

     # File lib/test/unit/ui/console/testrunner.rb, line 111
111:           def output_single(something, level=NORMAL)
112:             @io.write(something) if (output?(level))
113:             @io.flush
114:           end

[Source]

    # File lib/test/unit/ui/console/testrunner.rb, line 45
45:           def setup_mediator
46:             @mediator = create_mediator(@suite)
47:             suite_name = @suite.to_s
48:             if ( @suite.kind_of?(Module) )
49:               suite_name = @suite.name
50:             end
51:             output("Loaded suite #{suite_name}")
52:           end

[Source]

    # File lib/test/unit/ui/console/testrunner.rb, line 66
66:           def start_mediator
67:             return @mediator.run_suite
68:           end

[Source]

    # File lib/test/unit/ui/console/testrunner.rb, line 76
76:           def started(result)
77:             @result = result
78:             output("Started")
79:           end

[Source]

     # File lib/test/unit/ui/console/testrunner.rb, line 96
 96:           def test_finished(name)
 97:             output_single(".", PROGRESS_ONLY) unless (@already_outputted)
 98:             nl(VERBOSE)
 99:             @already_outputted = false
100:           end

[Source]

    # File lib/test/unit/ui/console/testrunner.rb, line 92
92:           def test_started(name)
93:             output_single(name + ": ", VERBOSE)
94:           end

[Validate]