Skip to content

Commit

Permalink
Merge pull request #12 from strido/retry-super-setup-cleanup
Browse files Browse the repository at this point in the history
Call all setup/cleanup methods in super specs when retrying
  • Loading branch information
anotherchrisberry committed Feb 13, 2016
2 parents 642ca0b + 6efe48f commit 2b269aa
Showing 1 changed file with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,28 @@ class RetryInterceptor implements IMethodInterceptor {
if (attempts > retryMax) {
throw t
}
invocation.spec.cleanupMethods.each {
try {
if (it.reflection) {
ReflectionUtil.invokeMethod(invocation.target, it.reflection)
invocation.spec.specsBottomToTop.each { spec ->
spec.cleanupMethods.each {
try {
if (it.reflection) {
ReflectionUtil.invokeMethod(invocation.target, it.reflection)
}
} catch (Throwable t2) {
LOG.warn("Retry caught failure ${attempts + 1} / ${retryMax + 1} while cleaning up", t2)
}
} catch (Throwable t2) {
LOG.warn("Retry caught failure ${attempts + 1} / ${retryMax + 1} while cleaning up", t2)
}
}
invocation.spec.setupMethods.each {
try {
if (it.reflection) {
ReflectionUtil.invokeMethod(invocation.target, it.reflection)
invocation.spec.specsTopToBottom.each { spec ->
spec.setupMethods.each {
try {
if (it.reflection) {
ReflectionUtil.invokeMethod(invocation.target, it.reflection)
}
} catch (Throwable t2) {
// increment counter, since this is the start of the re-run
attempts++
LOG.info("Retry caught failure ${attempts + 1} / ${retryMax + 1} while setting up", t2)
}
} catch (Throwable t2) {
// increment counter, since this is the start of the re-run
attempts++
LOG.info("Retry caught failure ${attempts + 1} / ${retryMax + 1} while setting up", t2)
}
}

Expand Down

0 comments on commit 2b269aa

Please sign in to comment.