Class: Test::Unit::UI::TestRunnerMediator
- Inherits:
-
Object
- Object
- Test::Unit::UI::TestRunnerMediator
- Includes:
- Test::Unit::Util::Observable
- Defined in:
- lib/test/unit/ui/testrunnermediator.rb
Overview
Provides an interface to write any given UI against, hopefully making it easy to write new UIs.
Constant Summary collapse
- RESET =
name + "::RESET"
- STARTED =
name + "::STARTED"
- FINISHED =
name + "::FINISHED"
Constants included from Test::Unit::Util::Observable
Test::Unit::Util::Observable::NOTHING
Instance Method Summary collapse
-
#initialize(suite, options = {}) ⇒ TestRunnerMediator
constructor
Creates a new TestRunnerMediator initialized to run the passed suite.
-
#run ⇒ Object
Runs the suite the TestRunnerMediator was created with.
-
#run_suite(result = nil, run_context: nil) ⇒ Object
Just for backward compatibility for NetBeans.
Methods included from Test::Unit::Util::Observable
#add_listener, #notify_listeners, #remove_listener
Constructor Details
#initialize(suite, options = {}) ⇒ TestRunnerMediator
Creates a new TestRunnerMediator initialized to run the passed suite.
26 27 28 29 30 31 |
# File 'lib/test/unit/ui/testrunnermediator.rb', line 26 def initialize(suite, ={}) @suite = suite = @test_suite_runner_class = [:test_suite_runner_class] @test_suite_runner_class ||= TestSuiteRunner end |
Instance Method Details
#run ⇒ Object
Runs the suite the TestRunnerMediator was created with.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/test/unit/ui/testrunnermediator.rb', line 35 def run AutoRunner.need_auto_run = false result = create_result = .dup # We should not keep @suite in @options because @options may # be live longer than this instance. For example, # AutoRunner's @runner_options is @options in this instance # and AutoRunner is live longer than this instance. We can # dup @options to avoid @suite's life time longer. [:test_suite] = @suite [:event_listener] = lambda do |channel, value| notify_listeners(channel, value) end Test::Unit.run_at_start_hooks start_time = Time.now begin with_listener(result) do @test_suite_runner_class.run_all_tests(result, ) do |run_context| catch do |stop_tag| result.stop_tag = stop_tag notify_listeners(RESET, @suite.size) notify_listeners(STARTED, result) run_suite(result, run_context: run_context) end end 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, run_context: nil) ⇒ Object
Just for backward compatibility for NetBeans. NetBeans should not use monkey patching. NetBeans should use runner change public API.
See GitHub#38
https://github.com/test-unit/test-unit/issues/38
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/test/unit/ui/testrunnermediator.rb', line 79 def run_suite(result=nil, run_context: nil) if result.nil? run else worker_context = WorkerContext.new(nil, run_context, result) @suite.run(worker_context) do |channel, value| notify_listeners(channel, value) end end end |