Class: Maze::RetryHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/maze/retry_handler.rb

Overview

Handles the logic of when a test should be retried after a failure. Note: This class expects a failed test. For repeating a single test see RepeatHandler

Constant Summary collapse

RETRY_TAGS =

Acceptable tags to indicate a test should be restarted

%w[@retry @retryable @retriable].freeze

Class Method Summary collapse

Class Method Details

.retried_previously?(test_case) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/maze/retry_handler.rb', line 32

def retried_previously?(test_case)
  global_retried[test_case] > 0
end

.should_retry?(test_case) ⇒ Boolean

Determines whether a failed test_case should be restarted

Parameters:

  • test_case (Cucumber::RunningTestCase)

    The current test_case or scenario

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/maze/retry_handler.rb', line 17

def should_retry?(test_case)
  # Only retry if the option is set and we haven't already retried
  return false if !Maze.config.enable_retries || retried_previously?(test_case)

  if retry_on_tag?(test_case)
    $logger.warn "Retrying #{test_case.name} due to retry tag"
  elsif Maze.dynamic_retry
    $logger.warn "Retrying #{test_case.name} due to dynamic retry set"
  else
    return false
  end
  increment_retry_count(test_case)
  true
end