valkolovos / gradle_cobertura

Gradle Cobertura Plugin
56 stars 17 forks source link

gradle build cobertura is deleting unit test reports #16

Open rebecca-draben opened 12 years ago

rebecca-draben commented 12 years ago

I am hoping someone here might be able to shed some light on my issue. I am a newbie to Gradle, Cobertura, and Sonar and I am trying to get them to play together nicely. I noticed that sometimes on my Sonar dashboard, my unit tests success was 100.0% for 34 tests and other times it just reported 0 tests. After some amount of digging, I found that

This works fine

gradle build gradle cobertura sonar

This causes sonar to report 0 tests

gradle build cobertura sonar

Why does it matter if I call them together or separately?

And upon some further digging, I found that sometimes my gradle generated unit test reports at build/reports/tests/index.html were there and sometimes they weren’t. And in fact

This works fine

gradle build gradle cobertura

This causes the unit test reports to be created and then deleted

gradle build cobertura

Any ideas would be greatly appreciated! And FWIW, I'm not seeing any error messages and everything else seems to be working correctly, including code coverage reporting in Sonar.

Thanks, WhatWouldHoneyBadgerDo

Here is my version information

$ gradle -v Gradle 1.0-milestone-8 Gradle build time: Monday, February 13, 2012 11:53:32 PM UTC Groovy: 1.8.4 Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010 Ivy: 2.2.0 JVM: 1.6.0_31 (Sun Microsystems Inc. 20.6-b01) OS: Linux 2.6.9-89.0.11.ELlargesmp amd64

Here is my build script (sorry, formatting seems to be lost)

apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'war' apply plugin: 'sonar' sourceCompatibility = 1.6 version = '1.0' implementationTitle = 'NameChangedToProtectTheInnocent' task createWrapper(type: Wrapper) { gradleVersion = '1.0-milestone-8' distributionBase = Wrapper.PathBase.PROJECT archiveBase = Wrapper.PathBase.PROJECT } repositories { mavenCentral() } dependencies { compile("log4j:log4j:1.2.16") compile("org.apache.httpcomponents:httpclient:4.1.3") compile("org.springframework:spring-web:3.1.1.RELEASE") testCompile("junit:junit:4.10") } jar { manifest { attributes 'Implementation-Title': implementationTitle, 'Implementation-Version': version } } sonar { project { coberturaReportPath = file("$buildDir/reports/cobertura/coverage.xml") } } buildscript { def githubBase = 'https://raw.github.com/valkolovos/gradle_cobertura/master/ivy' apply from: "${githubBase}/gradle_cobertura/gradle_cobertura/1.0-rc4/coberturainit.gradle" }

rebecca-draben commented 12 years ago

I looked at the execution order and noticed that when I run gradle build cobertura, the cleanTest task is executed after the test task. But when I run gradle build and then gradle cobertura, the cleanTest task is executed before the test task. That probably explains why all my unit test data is getting wiped out.

gradle build cobertura

:compileJava :processResources :classes :war :assemble :compileTestJava :processTestResources :testClasses :test Cobertura 1.9.4.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file Instrumenting 1 file Cobertura: Saved information on 10 classes. Instrument time: 2093ms Flushing results... Flushing results done Cobertura: Loaded information on 10 classes. Cobertura: Saved information on 10 classes. :check :build :cleanTest :coberturaXml Cobertura 1.9.4.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file Cobertura: Loaded information on 10 classes. Report time: 238ms :cobertura Cobertura 1.9.4.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file Cobertura: Loaded information on 10 classes. Report time: 462ms

gradle build gradle cobertura

:compileJava :processResources :classes :war :assemble :compileTestJava :processTestResources :testClasses :test :check :build :cleanTest :compileJava UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :compileTestJava UP-TO-DATE :processTestResources UP-TO-DATE :testClasses UP-TO-DATE :test Cobertura 1.9.4.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file Instrumenting 1 file Cobertura: Saved information on 10 classes. Instrument time: 718ms Flushing results... Flushing results done Cobertura: Loaded information on 10 classes. Cobertura: Saved information on 10 classes. :coberturaXml Cobertura 1.9.4.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file Cobertura: Loaded information on 10 classes. Report time: 326ms :cobertura Cobertura 1.9.4.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file Cobertura: Loaded information on 10 classes. Report time: 386ms

cmoesel commented 12 years ago

I've experienced this same thing-- and as far as I'm concerned, this is a blocker for me. Until it's fixed, I can't use this plugin... Is this something that can be fixed, or is it inherent in how the plugin must work?

mmbradle commented 11 years ago

+1