Class: MockTestHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/zombie-chaser/test_unit_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(results) ⇒ MockTestHandler

Returns a new instance of MockTestHandler.



52
53
54
55
56
# File 'lib/zombie-chaser/test_unit_handler.rb', line 52

def initialize(results)
  @results = results
  @result_queue = Queue.new
  @failure_encountered = false
end

Instance Attribute Details

#result_queueObject (readonly)

Returns the value of attribute result_queue.



50
51
52
# File 'lib/zombie-chaser/test_unit_handler.rb', line 50

def result_queue
  @result_queue
end

Instance Method Details

#runObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/zombie-chaser/test_unit_handler.rb', line 62

def run
  begin
    @results.each do |result|
      raise Timeout::Error, "Out of time" if result == :timeout
      @result_queue.enq(result)
      if result == :failure
        @failure_encountered = true
        break
      end
    end
  ensure
    @result_queue.enq(:end_of_work)
  end
  not @failure_encountered
end

#test_suite_sizeObject



58
59
60
# File 'lib/zombie-chaser/test_unit_handler.rb', line 58

def test_suite_size
  @results.size
end