Class: Test::Runner
- Inherits:
-
Object
- Object
- Test::Runner
- Defined in:
- lib/rubytest/runner.rb
Overview
The Test::Runner class handles the execution of tests.
Constant Summary collapse
- OPEN_ERRORS =
Exceptions that are not caught by test runner.
[NoMemoryError, SignalException, Interrupt, SystemExit]
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Handle all configuration via the config instance.
-
#observers ⇒ Object
readonly
Array of observers, typically this just contains the recorder and reporter instances.
-
#recorder ⇒ Object
readonly
Record pass, fail, error and pending tests.
-
#reporter ⇒ Object
readonly
The reporter to use for ouput.
Class Method Summary collapse
-
.run(config = nil, &config_proc) ⇒ Boolean
Run tests.
Instance Method Summary collapse
-
#advice ⇒ Object
Instance of Advice is a special customizable observer.
-
#after(type, &block) ⇒ Object
Define universal after advice.
-
#before(type, &block) ⇒ Object
Define universal before advice.
-
#format ⇒ Object
Reporter format name, or name fragment, used to look up reporter class.
-
#initialize(config) {|@config| ... } ⇒ Runner
constructor
New Runner.
-
#run ⇒ Boolean
Run test suite.
-
#suite ⇒ Object
Test suite to run.
-
#test_files ⇒ Object
TODO: Cache or not?.
-
#upon(type, &block) ⇒ Object
Define universal upon advice.
-
#verbose? ⇒ Boolean
Show extra details in reports.
Constructor Details
#initialize(config) {|@config| ... } ⇒ Runner
New Runner.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rubytest/runner.rb', line 51 def initialize(config) #:yield: @config = case config when Config then config when Hash then Config.new(config) else Test.configuration(config) end @config.apply! # apply lazy config block yield(@config) if block_given? @advice = Advice.new end |
Instance Attribute Details
#config ⇒ Object (readonly)
Handle all configuration via the config instance.
66 67 68 |
# File 'lib/rubytest/runner.rb', line 66 def config @config end |
#observers ⇒ Object (readonly)
Array of observers, typically this just contains the recorder and reporter instances.
122 123 124 |
# File 'lib/rubytest/runner.rb', line 122 def observers @observers end |
#recorder ⇒ Object (readonly)
Record pass, fail, error and pending tests.
118 119 120 |
# File 'lib/rubytest/runner.rb', line 118 def recorder @recorder end |
#reporter ⇒ Object (readonly)
The reporter to use for ouput.
115 116 117 |
# File 'lib/rubytest/runner.rb', line 115 def reporter @reporter end |
Class Method Details
Instance Method Details
#advice ⇒ Object
Instance of Advice is a special customizable observer.
92 93 94 |
# File 'lib/rubytest/runner.rb', line 92 def advice @advice end |
#after(type, &block) ⇒ Object
Define universal after advice. Can be used by mock libraries, for example to run mock verification.
103 104 105 |
# File 'lib/rubytest/runner.rb', line 103 def after(type, &block) advice.join_after(type, &block) end |
#before(type, &block) ⇒ Object
Define universal before advice.
97 98 99 |
# File 'lib/rubytest/runner.rb', line 97 def before(type, &block) advice.join_before(type, &block) end |
#format ⇒ Object
Reporter format name, or name fragment, used to look up reporter class.
82 83 84 |
# File 'lib/rubytest/runner.rb', line 82 def format config.format end |
#run ⇒ Boolean
Run test suite.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/rubytest/runner.rb', line 129 def run cd_chdir do Test::Config.load_path_setup if config.autopath? ignore_callers config.loadpath.flatten.each{ |path| $LOAD_PATH.unshift(path) } config.requires.flatten.each{ |file| require file } # Config before advice occurs after loadpath and require are # applied and before test files are required. config.before.call if config.before test_files.each do |test_file| require test_file end @reporter = reporter_load(format) @recorder = Recorder.new @observers = [advice, @recorder, @reporter] observers.each{ |o| o.begin_suite(suite) } run_thru(suite) observers.each{ |o| o.end_suite(suite) } config.after.call if config.after end recorder.success? end |
#suite ⇒ Object
Test suite to run. This is a list of compliant test units and test cases.
69 70 71 |
# File 'lib/rubytest/runner.rb', line 69 def suite config.suite end |
#test_files ⇒ Object
TODO: Cache or not?
76 77 78 79 |
# File 'lib/rubytest/runner.rb', line 76 def test_files #@test_files ||= resolve_test_files resolve_test_files end |
#upon(type, &block) ⇒ Object
Define universal upon advice.
See Advice for valid join-points.
110 111 112 |
# File 'lib/rubytest/runner.rb', line 110 def upon(type, &block) advice.join(type, &block) end |
#verbose? ⇒ Boolean
Show extra details in reports.
87 88 89 |
# File 'lib/rubytest/runner.rb', line 87 def verbose? config.verbose? end |