Class: Suture::TestsPatient

Inherits:
Object
  • Object
show all
Defined in:
lib/suture/tests_patient.rb

Instance Method Summary collapse

Instance Method Details

#test(test_plan) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/suture/tests_patient.rb', line 9

def test(test_plan)
  experienced_failure_in_life = false
  timer = Suture::Util::Timer.new(test_plan.time_limit) unless test_plan.time_limit.nil?
  test_cases = build_test_cases(test_plan)
  Value::TestResults.new(test_cases.each_with_index.map { |observation, i|
    if (test_plan.fail_fast && experienced_failure_in_life) ||
        (test_plan.call_limit && i >= test_plan.call_limit) ||
        (timer && timer.time_up?)
      {
        :observation => observation,
        :ran => false
      }
    else
      invoke(test_plan, observation).merge({
        :observation => observation,
        :ran => true
      }).tap { |r| experienced_failure_in_life = true unless r[:passed] }
    end
  })
end