Skip to content

Instantly share code, notes, and snippets.

@matzuk
Created November 26, 2019 14:37
Show Gist options
  • Save matzuk/e4376b817fb6d01f84148da006394564 to your computer and use it in GitHub Desktop.
Save matzuk/e4376b817fb6d01f84148da006394564 to your computer and use it in GitHub Desktop.
flakyBehaviorInterceptor.intercept(action = {
viewInteraction.perform(ViewAction)
}) {
var cachedException: Throwable
var startTime = System.currentTimeMillis()
do {
try {
return action.invoke()
} catch (e: Throwable) {
Thread.sleep(intervalMs)
cachedException = e
}
} while(System.currentTimeMillis() - startTime <= timeoutMs)
throw cachedException
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment