gradle_cobertura icon indicating copy to clipboard operation
gradle_cobertura copied to clipboard

Cobertura won't run if there are test failures.

Open stevesaliman opened this issue 12 years ago • 7 comments

I wanted to talk about a proposed change with you. I can fork the project and do part of it, but I'm not sure I'd get the rest of it to work, and being pretty new to Gradle and Groovy, I don't know if my testing efforts would be up to par. I'd probably need some help with it.

The issue: When the cobertura plugin is applied, it creates a cobertura task, dependent on test tasks, to generate the cobertura reports. but if the tests have any failures, the cobertura task won't run, so we get no coverage reports if any of the tests fail.

The solution: There are 3 things we'd need to do to work around this.

  1. We'd need to tell the test tasks to ignore failures so the cobertura task would run always.
  2. We'd need to register a listener with each task to set a project property if any tests fail.
  3. We'd need to have the cobertura task check this property and fail the build if set.

I'm pretty confident that I can tackle the first 2, but I'm not sure exactly where in the code to put #3.

If we really wanted to be complete about it, we'd add an "ignoreFailures" property to the cobertura plugin that allowed users to decide if a failure should be ignored or not when we do #3.

I also saw that there is a current issue request to publish the plugin to Maven Central. Aside from being easier to use, it would also put (I think) the plugin classes in the build's classpath, which gives us some more options when working with the plugin. I've recently done this on a plugin of mine, and I could do this for the cobertura plugin as well - though it would need to use my Maven groupId. Gradle released the first release candidate for version 1.1, and it seems to be having some issues with the "apply from:" syntax the plugin currently requires. Publishing to Maven Central would fix this.

What do you think?

Steve

stevesaliman avatar Jul 24 '12 18:07 stevesaliman