Gradle 1.4 has new test report aggregate task:
http://www.gradle.org/docs/current/release-notes#stand-alone-test-report-task
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports/all-tests")
reportOn subprojects*.test
}
Is there a way to make this task run even when build fails? Currently if I do:
taskReport.dependsOn test
build.dependsOn taskReport
it executes only if build is success.
Good news first: Upcoming enhancements to Gradle’s task model, currently scheduled for Gradle 1.6, will address this and similar use cases.
Meanwhile, the possibilities are limited. One option is to run with
--continue, although this will continue with other tasks as well. Another potential option is to register aorg.gradle.api.execution.TaskExecutionListener(viagradle.project.addListener()) and have it calltestReport.generateReport()after aTesttask has failed. Although calling a task directly is heavily discouraged (and often won’t produce the expected behavior), it might do as a temporary workaround in this particular case.