Class: TestUnitHandler
- Inherits:
-
Object
- Object
- TestUnitHandler
- Defined in:
- lib/test_unit_handler.rb
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#initialize(test_pattern, actor) ⇒ TestUnitHandler
constructor
A new instance of TestUnitHandler.
- #run ⇒ Object
- #test_failed ⇒ Object
- #test_finished ⇒ Object
Constructor Details
#initialize(test_pattern, actor) ⇒ TestUnitHandler
Returns a new instance of TestUnitHandler.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/test_unit_handler.rb', line 7 def initialize(test_pattern, actor) @actor = actor raise "Error: can't detect any files in test pattern \"#{test_pattern} (Don't forget to use forward slashes even in Windows)" if Dir.glob(test_pattern).empty? Dir.glob(test_pattern).each {|test| require test} #In heckle, this is separated out @finished = false @results = [] @step_count = 0 obj_sp = Test::Unit::Collector::ObjectSpace.new test_suite = Test::Unit::TestSuite.new("Mutation slayer test suite") test_suite << obj_sp.collect @test_runner_mediator = Test::Unit::UI::TestRunnerMediator.new(test_suite) @test_runner_mediator.add_listener(Test::Unit::TestResult::FAULT) {test_failed} @test_runner_mediator.add_listener(Test::Unit::TestCase::FINISHED) {test_finished} end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
5 6 7 |
# File 'lib/test_unit_handler.rb', line 5 def results @results end |
Instance Method Details
#run ⇒ Object
23 24 25 26 27 |
# File 'lib/test_unit_handler.rb', line 23 def run catch(:stop_test_runner) do @test_runner_mediator.run_suite end end |
#test_failed ⇒ Object
29 30 31 32 33 34 |
# File 'lib/test_unit_handler.rb', line 29 def test_failed @results << :failure @actor.notify_failing_step sleep 0.5 throw :stop_test_runner end |
#test_finished ⇒ Object
36 37 38 39 40 |
# File 'lib/test_unit_handler.rb', line 36 def test_finished sleep 0.1 #Hack to avoid it being too quick @results << :pass @actor.notify_passing_step end |