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
20 21 22 |
# File 'lib/ndr_dev_support/integration_testing/flakey_tests.rb', line 20 def flakes @flakes ||= [] end |
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ndr_dev_support/integration_testing/flakey_tests.rb', line 24 def run attempts_remaining = attempts_per_test[name] return super unless attempts_remaining previous_failure = failures.last failed_attempts = [] loop do break if attempts_remaining < 1 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 self end |