Skip to content

Instantly share code, notes, and snippets.

@bsideup
Created July 9, 2019 09:25
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 bsideup/99ad16f525f580ed1be1889fd4b4c337 to your computer and use it in GitHub Desktop.
Save bsideup/99ad16f525f580ed1be1889fd4b4c337 to your computer and use it in GitHub Desktop.
tasks.withType(Test) {
if (name.endsWith("Rerun")) {
// Avoid recursion
return
}
def rerunTask = tasks.register("${name}Rerun", Test) {
// Enabled only when there are failures (see `afterTest`)
enabled = false
failFast = true // ¯\_(ツ)_/¯
outputs.upToDateWhen { false }
}
ignoreFailures = true
finalizedBy(rerunTask)
afterTest { desc, result ->
if (TestResult.ResultType.FAILURE == result.resultType) {
rerunTask.configure {
enabled = true
filter.includeTestsMatching("${desc.className}.${desc.name}")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment