From a92d4aa7e8078f940a1284e93124039f8fec6e96 Mon Sep 17 00:00:00 2001 From: Nick Muerdter <12112+GUI@users.noreply.github.com> Date: Wed, 17 Apr 2024 12:18:55 -0600 Subject: [PATCH] Add retry behavior to help with persistently flaky tests. --- Gemfile | 3 +++ Gemfile.lock | 3 +++ test/support/retry.rb | 13 +++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 test/support/retry.rb diff --git a/Gemfile b/Gemfile index 8b9f36dbe..e9a4c8029 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,9 @@ gem "minitest-reporters", "~> 1.6.0" # For an "after_all" callback. gem "minitest-hooks", "~> 1.5.0" +# Retry certain flaky tests. +gem "minitest-retry", "~> 0.2.2" + # Test metadata for CI environment. gem "minitest-ci", "~> 3.4.0" diff --git a/Gemfile.lock b/Gemfile.lock index 23dfe4123..c2152a5c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,6 +105,8 @@ GEM builder minitest (>= 5.0) ruby-progressbar + minitest-retry (0.2.2) + minitest (>= 5.0) minitest-sprint (1.2.2) path_expander (~> 1.1) multi_json (1.15.0) @@ -213,6 +215,7 @@ DEPENDENCIES minitest-ci (~> 3.4.0) minitest-hooks (~> 1.5.0) minitest-reporters (~> 1.6.0) + minitest-retry (~> 0.2.2) minitest-sprint (~> 1.2.0) multi_json (~> 1.15.0) net-smtp (~> 0.5.0) diff --git a/test/support/retry.rb b/test/support/retry.rb new file mode 100644 index 000000000..b83cf0bf2 --- /dev/null +++ b/test/support/retry.rb @@ -0,0 +1,13 @@ +# While not ideal, retry certain flaky tests in CI. +if ENV["CI"] == "true" + require "minitest/retry" + Minitest::Retry.use!( + methods_to_retry: [ + "Test::AdminUi::TestApis#test_form", + ], + + exceptions_to_retry: [ + Selenium::WebDriver::Error::UnknownError, + ], + ) +end