Class: Maze::RetryHandler
- Inherits:
-
Object
- Object
- Maze::RetryHandler
- 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
- .retried_previously?(test_case) ⇒ Boolean
-
.should_retry?(test_case, event) ⇒ Boolean
Determines whether a failed test_case should be restarted.
Class Method Details
.retried_previously?(test_case) ⇒ Boolean
46 47 48 |
# File 'lib/maze/retry_handler.rb', line 46 def retried_previously?(test_case) global_retried[test_case] > 0 end |
.should_retry?(test_case, event) ⇒ Boolean
Determines whether a failed test_case should be restarted
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/maze/retry_handler.rb', line 18 def should_retry?(test_case, event) # 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_driver_error?(event) if Maze.driver.is_a?(Maze::Driver::Appium) if Maze.config.farm.eql?(:bb) Maze::Hooks::ErrorCodeHook.exit_code = Maze::Api::ExitCode::APPIUM_SESSION_FAILURE return false else $logger.warn "Retrying #{test_case.name} due to appium driver error: #{event.result.exception}" Maze.driver.restart end elsif Maze.driver.is_a?(Maze::Driver::Browser) $logger.warn "Retrying #{test_case.name} due to selenium driver error: #{event.result.exception}" Maze.driver.refresh end elsif 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 |