I am currently prototyping the migration from maven to gradle.
In the current maven projects, we are failing the build on insufficient test coverage.
I already use the jacoco plugin for gradle and I’m able to generate the report, but I don’t see how to fail the build.
For reference, in maven there is a specific plugin task named check for this purpose.
You could try putting a dependency of the primary build task (build) on the jacoco task. So if ‘jacoco’ fails, then ‘build’ fails too.
The problem is that I have no access to the coverage values, the jacoco reports task is not failing.
If you look at the ant task http://www.eclemma.org/jacoco/trunk/doc/ant.html there is an Element check that was not included in the jacoco gradle plugin.
The check element is currently not supported by the Jacoco plugin. Please also see GRADLE-2854 and GRADLE-2783. Please vote on the issue in JIRA to increase the likelihood of it getting implemented.
As a workaround you could have a task that parses the Jacoco report for these metrics and then fail the build if thresholds are not met.
Thanks for the answer, will do that