Class: Turn::MiniRunner
- Inherits:
-
MiniTest::Unit
- Object
- MiniTest::Unit
- Turn::MiniRunner
- Defined in:
- lib/turn/runners/minirunner.rb
Overview
Turn’s MiniTest test runner class.
Instance Method Summary collapse
-
#_run_suite(suite, type) ⇒ Object
Override #_run_suite to iterate tests via Turn.
-
#_run_suites(suites, type) ⇒ Object
Override #_run_suite to setup Turn.
-
#initialize ⇒ MiniRunner
constructor
A new instance of MiniRunner.
-
#output ⇒ Object
route minitests traditional output to nowhere.
-
#puke(klass, meth, err) ⇒ Object
Override #puke to update Turn’s internals and reporter.
-
#start(args = []) ⇒ Object
Turn calls this method to start the test run.
- #turn_reporter ⇒ Object
Constructor Details
#initialize ⇒ MiniRunner
Returns a new instance of MiniRunner.
15 16 17 18 19 20 21 22 |
# File 'lib/turn/runners/minirunner.rb', line 15 def initialize @turn_config = Turn.config super() # a stream we will use to route minitests traditional output @out = ::StringIO.new end |
Instance Method Details
#_run_suite(suite, type) ⇒ Object
Override #_run_suite to iterate tests via Turn.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/turn/runners/minirunner.rb', line 69 def _run_suite suite, type # suites are cases in minitest @turn_case = @turn_suite.new_case(suite.name) filter = normalize_filter(@options[:filter]) || @turn_config.pattern || /./ suite.send("#{type}_methods").grep(/#{filter}/).each do |test| @turn_case.new_test(test) end turn_reporter.start_case(@turn_case) header = "#{type}_suite_header" puts send(header, suite) if respond_to? header assertions = @turn_case.tests.map do |test| @turn_test = test turn_reporter.start_test(@turn_test) inst = suite.new(test.name) #method inst._assertions = 0 result = inst.run self if result == "." turn_reporter.pass end turn_reporter.finish_test(@turn_test) inst._assertions end @turn_case.count_assertions = assertions.inject(0) { |sum, n| sum + n } turn_reporter.finish_case(@turn_case) return assertions.size, assertions.inject(0) { |sum, n| sum + n } end |
#_run_suites(suites, type) ⇒ Object
Override #_run_suite to setup Turn.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/turn/runners/minirunner.rb', line 46 def _run_suites suites, type # Someone want to explain to me why these are fucking here? suites = suites - [MiniTest::Spec] suites = suites - [Test::Unit::TestCase] if defined?(Test::Unit::TestCase) @turn_suite = Turn::TestSuite.new(@turn_config.suite_name) @turn_suite.size = suites.size #::MiniTest::Unit::TestCase.test_suites.size @turn_suite.seed = ::MiniTest::Unit.runner.[:seed] turn_reporter.start_suite(@turn_suite) if @turn_config.matchcase suites = suites.select{ |suite| @turn_config.matchcase =~ suite.name } end result = suites.map { |suite| _run_suite(suite, type) } turn_reporter.finish_suite(@turn_suite) return result end |
#output ⇒ Object
route minitests traditional output to nowhere
25 26 27 |
# File 'lib/turn/runners/minirunner.rb', line 25 def output @out end |
#puke(klass, meth, err) ⇒ Object
Override #puke to update Turn’s internals and reporter.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/turn/runners/minirunner.rb', line 110 def puke(klass, meth, err) case err when MiniTest::Skip @turn_test.skip!(err) turn_reporter.skip(err) when MiniTest::Assertion @turn_test.fail!(err) turn_reporter.fail(err) else @turn_test.error!(err) turn_reporter.error(err) end super(klass, meth, err) end |
#start(args = []) ⇒ Object
Turn calls this method to start the test run.
35 36 37 38 39 40 41 42 43 |
# File 'lib/turn/runners/minirunner.rb', line 35 def start(args=[]) # minitest changed #run in 6023c879cf3d5169953e on April 6th, 2011 if ::MiniTest::Unit.respond_to?(:runner=) ::MiniTest::Unit.runner = self end # FIXME: why isn't @test_count set? run(args) return @turn_suite end |
#turn_reporter ⇒ Object
30 31 32 |
# File 'lib/turn/runners/minirunner.rb', line 30 def turn_reporter @turn_config.reporter end |