hello federico, the configuration for rerunning failing tests in a second test task can look like this:
test{
useTestNG()
ignoreFailures = true
}
task secondTry(type:Test){
onlyIf{
file("build/reports/tests/testng-failed.xml").exists()
}
dependsOn test
testClassesDir = sourceSets.test.output.classesDir
classpath = sourceSets.test.runtimeClasspath
testSrcDirs = sourceSets.test.java.srcDirs as List
testReportDir = file("$buildDir/reports/secondTry")
useTestNG(){
suites("build/reports/tests/testng-failed.xml")
}
}
task allTests(dependsOn: tasks.withType(Test))
just run “gradle alltests” and if all tests pass on the first try, the secondTry task is skipped. If the test task has failed tests, the secondTry test task retries them.
Have a look at the DSL reference of the Test task for details (http://gradle.org/docs/current/dsl/org.gradle.api.tasks.testing.Test.html)
regards, René