Skip to content

Instantly share code, notes, and snippets.

@cyrilchampier
Created December 20, 2018 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyrilchampier/91c94e22f3a119ebaa12a25e57e73136 to your computer and use it in GitHub Desktop.
Save cyrilchampier/91c94e22f3a119ebaa12a25e57e73136 to your computer and use it in GitHub Desktop.
minitest override for flaky retry
def run
try_results = []
loop do
try_results << super
if self.class.disable_retry || try_results.count >= MAX_TRIES || try_results.last.failure.nil?
break
else
reset_state
end
end
if try_results.first.failure.present? && try_results.last.failure.nil?
if SentryReporter.enabled?
SentryReporter.report(try_results.first, try_results.count)
else
warn("Test #{try_results.first.class}##{try_results.first.name} is flaky.")
end
end
try_results.last
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment