Class: Test::Unit::UI::TestRunnerMediator
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | lib/test/unit/ui/testrunnermediator.rb |
Overview
Provides an interface to write any given ::Test::Unit::UI against, hopefully making it easy to write new UIs.
Constant Summary
-
FINISHED =
# File 'lib/test/unit/ui/testrunnermediator.rb', line 20name + "::FINISHED"
-
RESET =
# File 'lib/test/unit/ui/testrunnermediator.rb', line 18name + "::RESET"
-
STARTED =
# File 'lib/test/unit/ui/testrunnermediator.rb', line 19name + "::STARTED"
::Test::Unit::Util::Observable - Included
Class Method Summary
-
.new(suite) ⇒ TestRunnerMediator
constructor
Creates a new
TestRunnerMediator
initialized to run the passed suite.
Instance Method Summary
-
#run
Runs the suite the
TestRunnerMediator
was created with. -
#run_suite(result = nil)
Just for backward compatibility for NetBeans.
-
#create_result
private
A factory method to create the result the mediator should run with.
- #measure_time private
- #with_listener(result) private
::Test::Unit::Util::Observable - Included
#add_listener | Adds the passed proc as a listener on the channel indicated by channel_name. |
#notify_listeners | Calls all the procs registered on the channel indicated by channel_name. |
#remove_listener | Removes the listener indicated by listener_key from the channel indicated by channel_name. |
#channels |
Constructor Details
.new(suite) ⇒ TestRunnerMediator
Creates a new TestRunnerMediator
initialized to run the passed suite.
# File 'lib/test/unit/ui/testrunnermediator.rb', line 26
def initialize(suite) @suite = suite end
Instance Method Details
#create_result (private)
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.
# File 'lib/test/unit/ui/testrunnermediator.rb', line 75
def create_result TestResult.new end
#measure_time (private)
[ GitHub ]# File 'lib/test/unit/ui/testrunnermediator.rb', line 79
def measure_time begin_time = Time.now yield Time.now - begin_time end
#run
Runs the suite the TestRunnerMediator
was created with.
# File 'lib/test/unit/ui/testrunnermediator.rb', line 32
def run AutoRunner.need_auto_run = false result = create_result Test::Unit.run_at_start_hooks start_time = Time.now begin with_listener(result) do notify_listeners(RESET, @suite.size) notify_listeners(STARTED, result) run_suite(result) end ensure elapsed_time = Time.now - start_time notify_listeners(FINISHED, elapsed_time) end Test::Unit.run_at_exit_hooks result end
#run_suite(result = nil)
Just for backward compatibility for NetBeans. NetBeans should not use monkey patching. NetBeans should use runner change public API.
See GitHub#38 github.com/test-unit/test-unit/issues/38
#with_listener(result) (private)
[ GitHub ]# File 'lib/test/unit/ui/testrunnermediator.rb', line 85
def with_listener(result) finished_listener = result.add_listener(TestResult::FINISHED) do |*args| notify_listeners(TestResult::FINISHED, *args) end changed_listener = result.add_listener(TestResult::CHANGED) do |*args| notify_listeners(TestResult::CHANGED, *args) end pass_assertion_listener = result.add_listener(TestResult::PASS_ASSERTION) do |*args| notify_listeners(TestResult::PASS_ASSERTION, *args) end fault_listener = result.add_listener(TestResult::FAULT) do |*args| notify_listeners(TestResult::FAULT, *args) end begin yield ensure result.remove_listener(TestResult::FAULT, fault_listener) result.remove_listener(TestResult::CHANGED, changed_listener) result.remove_listener(TestResult::FINISHED, finished_listener) result.remove_listener(TestResult::PASS_ASSERTION, pass_assertion_listener) end end