Module: NdrDevSupport::IntegrationTesting::FlakeyTests
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/ndr_dev_support/integration_testing/flakey_tests.rb
Overview
Grudging handling of flakey integration tests. Allows tests to be declared with ‘flakey_test`. Our CI reporter gathers information on flakey failures.
Instance Method Summary collapse
Instance Method Details
#flakes ⇒ Object
26 27 28 |
# File 'lib/ndr_dev_support/integration_testing/flakey_tests.rb', line 26 def flakes @flakes ||= [] end |
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ndr_dev_support/integration_testing/flakey_tests.rb', line 30 def run attempts_remaining = attempts_per_test[name] return super unless attempts_remaining previous_failure = failures.last failed_attempts = [] result = nil loop do break if attempts_remaining < 1 result = super # No failure was added; we passed! break if failures.last == previous_failure # Ran out of attempts: break if (attempts_remaining -= 1) < 1 # Loop round and have another go: failed_attempts << failures.pop end # Attempts were only flakey if we eventually passed: flakes.concat(failed_attempts) if failures.last == previous_failure result end |