-
-
Save bsideup/99ad16f525f580ed1be1889fd4b4c337 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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