Class Test::Unit::UI::TestRunnerMediator
In: lib/test/unit/ui/testrunnermediator.rb
Parent: Object

Provides an interface to write any given UI against, hopefully making it easy to write new UIs.

Methods

Included Modules

Util::Observable

Constants

RESET = name + "::RESET"
STARTED = name + "::STARTED"
FINISHED = name + "::FINISHED"

Public Class methods

Creates a new TestRunnerMediator initialized to run the passed suite.

[Source]

    # File lib/test/unit/ui/testrunnermediator.rb, line 26
26:         def initialize(suite)
27:           @suite = suite
28:         end

Public Instance methods

Runs the suite the TestRunnerMediator was created with.

[Source]

    # File lib/test/unit/ui/testrunnermediator.rb, line 32
32:         def run_suite
33:           Unit.run = true
34:           begin_time = Time.now
35:           notify_listeners(RESET, @suite.size)
36:           result = create_result
37:           notify_listeners(STARTED, result)
38:           result_listener = result.add_listener(TestResult::CHANGED) do |updated_result|
39:             notify_listeners(TestResult::CHANGED, updated_result)
40:           end
41:           
42:           fault_listener = result.add_listener(TestResult::FAULT) do |fault|
43:             notify_listeners(TestResult::FAULT, fault)
44:           end
45:           
46:           @suite.run(result) do |channel, value|
47:             notify_listeners(channel, value)
48:           end
49:           
50:           result.remove_listener(TestResult::FAULT, fault_listener)
51:           result.remove_listener(TestResult::CHANGED, result_listener)
52:           end_time = Time.now
53:           elapsed_time = end_time - begin_time
54:           notify_listeners(FINISHED, elapsed_time) #"Finished in #{elapsed_time} seconds.")
55:           return result
56:         end

Private Instance methods

A factory method to create the result the mediator should run with. Can be overridden by subclasses if one wants to use a different result.

[Source]

    # File lib/test/unit/ui/testrunnermediator.rb, line 62
62:         def create_result
63:           return TestResult.new
64:         end

[Validate]