Is there a way I can set up Gradle so that it doesn’t immediately fail if there are test problems, but sets a property so I can fail the build later? Here is my scenario:
I want to use the Cobertura plugin in my build, and I want it to generate a report every time the build runs. The cobertura plugin adds a “cobertura” task that generates the report, and it depends on the test task. The problem is, if any of the tests fail the cobertura task doesn’t run. I can put “test.ignoreFailures=true” to get the cobertura task to run regardless, but then it will continue on after that as if all was well, and it will ultimately report build success, which is not good for a CI environment.
What I’d like to do is have a task that depends on the cobertura task, but would throw an exception if the test task had any failed tests. This would let me generate a coverage report every time, but I can abort the build if a test failed - after the reports were generated. It is similar to the way Ant users use the errorproperty and failure property in the junit task.
Is this something that can be done in Gradle?