Giter Site home page Giter Site logo

gradle-cobertura-plugin's People

Contributors

cverdoes avatar dampcake avatar davejsmith avatar felixbarny avatar johnrengelman avatar kageiit avatar lampietti avatar maddingo avatar manuelprinz avatar mfarid avatar owahlen avatar rpalcolea avatar saqib-ahmed avatar spina avatar sragu avatar stevesaliman avatar surfing avatar t-botz avatar thadguidry avatar trnl avatar vyazelenko avatar wiomoc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gradle-cobertura-plugin's Issues

In a multiproject all projects must have cobertura plugin applied in order to make the plugin working

A have a multi project with a lot of sub projects. I apply the cobertura plugin only to my production projects (since I don't want to generate report for my mock projects). It sees not to work.

Execute:

./gradlew clean cobertura build

Gradle reports:

* What went wrong:
Extension with name 'cobertura' does not exist. Currently registered extension names: [ext, defaultArtifacts, reporting]

If I apply the plugin to all sub projects then it works as expected.

NullPointerException on applying plugin after groovy plugin (2.2.0-SNAPSHOT)

Using recent snapshot I've got NPE when cobertura plugin is applied after groovy plugin (it works fine when applied before).

Applying cobertura plugin to gradle-pitest-plugin
creating extension

FAILURE: Build failed with an exception.

* Where:
Build file '/home/foo/gradle-pitest-plugin/build.gradle' line: 5

* What went wrong:
A problem occurred evaluating root project 'gradle-pitest-plugin'.
> Could not create an instance of type net.saliman.gradle.plugin.cobertura.CoberturaExtension_Decorated.

with root cause:

Caused by: java.lang.NullPointerException
    at net.saliman.gradle.plugin.cobertura.CoberturaExtension_Decorated.getProperty(Unknown Source)
    at net.saliman.gradle.plugin.cobertura.CoberturaExtension$_closure3.doCall(CoberturaExtension.groovy:220)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
    at org.gradle.api.internal.Actions$FilteredAction.execute(Actions.java:203)
    at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:110)
    at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:115)
    at org.gradle.api.internal.DefaultDomainObjectCollection.withType(DefaultDomainObjectCollection.java:126)
    at org.gradle.api.DomainObjectCollection$withType.call(Unknown Source)
    at net.saliman.gradle.plugin.cobertura.CoberturaExtension.<init>(CoberturaExtension.groovy:219)
    at net.saliman.gradle.plugin.cobertura.CoberturaExtension_Decorated.<init>(Unknown Source)
    at org.gradle.internal.reflect.DirectInstantiator.newInstance(DirectInstantiator.java:39)
    ... 70 more

Possible instrumentation problem under Windows 7, Cygwin, JDK 1.7.0_09

Under JDK 1.7.0_09 on Windows 7 with Cygwin, I see the following with many (all?) of my test classes:

java.lang.VerifyError: Instruction type does not match stack map in method package.ClassName.method(signature) at offset NNN
    at package.ClassNameTest.testMethod(ClassNameTest.java:NNN)

Running the same build under Linux Mint 12, JDK 1.6.0_26 does not exhibit the same problems.

I'll see if I can put together a minimal test case for this when I can catch a spare moment.

log4j ConsoleAppender assignment failed

:[project]:instrument
Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [java.net.URLClassLoader@234d5408] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [org.gradle.util.MutableURLClassLoader@398b0a62].
log4j:ERROR Could not instantiate appender named "console".

Gradle Cobertura plugin tasks are always skipped

All of a sudden, I have started seeing an issue where not matter what I do, Gradle appears to be skipping the instrument, copyCoberturaDatafile, generateCoberturaReport and performCoverageCheck tasks when building a Gradle project. The project in question uses the following plugins:

  1. java
  2. groovy
  3. maven
  4. cobertura

I am pretty sure that this was working not too long ago. The only thing that I believe that might have changed is an update from Gradle 1.10 to 1.11. The project in question uses Spock for the unit tests and is using the following test and cobertura configuration in the build.gradle script:

test {
    filter {
        includeTestsMatching "*Test"
        includeTestsMatching "*Spec"
    }
}

cobertura {
    coverageFormats = ['html', 'xml']
    coverageIgnoreTrivial = true
    coverageIgnores = ['org.slf4j.Logger.*']
    coverageReportDir = new File("$buildDir/reports/cobertura")
}

I have tried versions 2.2.2, 2.2.3 and 2.2.4 of the plugin, all with the same results. Removing the build directory and/or modifying source files does not appear to have any affect, as the tasks are always skipped. I also tried providing explicitly the tasks to trigger the instrumentation (per the configuration options), but no luck. My suspicion is that perhaps a subtle API change between Gradle 1.10 and 1.11 has affected the tasks. I am going to try to downgrade to Gradle 1.10 and see if the coverage works.

Report skipped in Groovy project

It seems that the instrumentation and coberturaReport task are skipped if only Groovy-Code changes (Task compileGroovy) and no Java-Code changes (Task compileJava).
Due to the source code, instrumentation is based on compileJava and ignores compileGroovy. May be it would besser to depend on Task classes.

Instrument task only

I would like to run only instrument task (without running tests and generating report), but I always get 'SKIPPED'. Is it possible with your plugin?

EDIT: ok, it is possible. It must be run coberturaReport task before

Invalid Inner Class Name during Instrument

Unable to instrument file /Users/brianhuddleston/Dropbox/sbi-api/build/instrumented_classes/com/dg/api/CacheModule$1.class
java.lang.IllegalArgumentException: Invalid inner class name (must be a valid Java identifier): 1

The code snippet in question looks like this:

private static LoadingCache<String, String> leaderCache =
        CacheBuilder.newBuilder().maximumSize(10000).expireAfterWrite(3, TimeUnit.HOURS).recordStats()
                .build(new CacheLoader<String, String>() {
            @Override
            String load(String key) throws Exception {
                log.info("Fetching leaderBoard $key from source")
                def (boardId, fieldList) = key.split(/\|/)
                BrandList.getLeaderListJson(Long.parseLong(boardId.toString()), fieldList.toString())
            }
        })

Full stacktrace is:

Unable to instrument file /Users/brianhuddleston/Dropbox/sbi-api/build/instrumented_classes/com/dg/api/CacheModule$1.class
java.lang.IllegalArgumentException: Invalid inner class name (must be a valid Java identifier): 1
at org.objectweb.asm.util.CheckMethodAdapter.checkIdentifier(Unknown Source)
at org.objectweb.asm.util.CheckMethodAdapter.checkIdentifier(Unknown Source)
at org.objectweb.asm.util.CheckClassAdapter.visitInnerClass(Unknown Source)
at org.objectweb.asm.ClassVisitor.visitInnerClass(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:153)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234)
at net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:298)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:307)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:399)
at net.sourceforge.cobertura.instrument.Main.main(Main.java:421)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.invoke(PojoMetaMethodSite.java:189)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at net.saliman.gradle.plugin.cobertura.CoberturaRunner.executeCobertura(CoberturaRunner.groovy:199)
at net.saliman.gradle.plugin.cobertura.CoberturaRunner.this$2$executeCobertura(CoberturaRunner.groovy)
at net.saliman.gradle.plugin.cobertura.CoberturaRunner$this$2$executeCobertura.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153)
at net.saliman.gradle.plugin.cobertura.CoberturaRunner.instrument(CoberturaRunner.groovy:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:226)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:64)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at net.saliman.gradle.plugin.cobertura.InstrumentTask.instrument(InstrumentTask.groovy:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.util.JavaMethod.invoke(JavaMethod.java:62)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:527)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:510)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:283)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$1.run(DefaultTaskPlanExecutor.java:33)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:214)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:276)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:142)
at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:78)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:31)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:46)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.Main.main(Main.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)

Add an option to defer build failure so that all test tasks run.

In version 1.x of the plugin, failures in test tasks were intercepted and delayed until after the coverage reports ran. This had the side effect of making sure all test tasks would run before generating the coverage report.

In version 2.0.0 of the plugin, I switched to the much simpler `finalizedBy`` mechanism of making sure reports would be generated after failed tests. When a test failure happens, Gradle won't run any new tasks, except for tasks needed to finalize tasks that have already run. This has the side effect of generating reports that exclude tests run from tasks downstream of the failed one.

I don't want to restore the old behavior as a default because I don't want to inject myself into Gradle's sense of what should run and what shouldn't, but I do want to restore the old behavior as an option for those who:

  1. Don't have anything of importance running between the tests and the report generation and;
  2. Want to make sure all tests run so that the coverage report is accurate with respect to all of the tests.

Add possibility to define more that one report type

Currently it is possible to add only one format of Cobertura. In reality it is sometimes necessary to generate e.g. two types of reports from same Cobertura run. For example when using Sonar in project you should provide *.xml file with coverage report. But in the same time it is also necessary to generate html report for humans. It's not easy to overcome this problem, but implementing it in plugin code is very simple (at least in the simplest version). I had to implement it myself to use reports in Sonar.
My changes:

In file: CoberturaExtension.groovy

/**
* Formats of cobertura report. Default is only 'html'
*/
Set<String> coverageFormat = ['html']

In file: CoberturaPlugin.groovy insert in line no. 102:

Set<String> formats = task.project.extensions.cobertura.coverageFormat
for(format in formats) {
  task.project.coberturaRunner.generateCoverageReport 
  task.project.extensions.cobertura.coverageDatafile.path, 
  task.project.extensions.cobertura.coverageReportDir.path, format, 
  task.project.files(task.project.extensions.cobertura.coverageSourceDirs).files.collect { it.path }
}

It is very simplistic implementation but works very well.

Possible extension would be to define format and report output directories in pairs, so that every report can be generated do different directory.

CoberturaPlugin uses deprecated ConfigurationContainer.add()

apply plugin: 'java'
...
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "net.saliman:gradle-cobertura-plugin:1.1.2"
    }
}

apply plugin: 'cobertura'

Gradle 1.6 output:

The ConfigurationContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
The TaskContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.

Could not find method create()

I am trying to incorporate the cobertura plugin. I am getting the following exception when I run any task like build or test.

  • Where:
    Build file '/Users/msinghi/Dev/service-registry/build.gradle' line: 46

  • What went wrong:
    A problem occurred evaluating root project 'service-registry'.

    Could not find method create() for arguments [{name=instrument, type=class net.saliman.gradle.plugin.cobertura.InstrumentTask}, net.saliman.gradle.plugin.cobertura.CoberturaPlugin$_apply_closure3@21ad125b] on task set.

Caused by: org.gradle.api.internal.MissingMethodException: Could not find method create() for arguments [{name=instrument, type=class net.saliman.gradle.plugin.cobertura.InstrumentTask}, net.saliman.gradle.plugin.cobertura.CoberturaPlugin$_apply_closure3@1ad46fd4] on task set.
at org.gradle.api.internal.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:68)
at org.gradle.api.internal.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:56)

I am using Java 7 and My build.gradle looks like this -

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'

repositories {
mavenCentral()
maven {
url "http://files.couchbase.com/maven2/"
}
}

dependencies {
compile "javax.ws.rs:jsr311-api:1.1.1"
compile 'couchbase:couchbase-client:1.1.9'
compile 'org.glassfish.jersey.ext:jersey-spring3:2.2'

compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.2'

compile 'org.glassfish.jersey.ext:jersey-bean-validation:2.2'
compile 'ch.qos.logback:logback-classic:1.0.13'
compile 'ch.qos.logback:logback-access:1.0.13'

testCompile "junit:junit-dep:4.11"
testCompile "org.mockito:mockito-core:1.9.5"

}

task wrapper(type: Wrapper) {
gradleVersion = '1.7'
}

apply plugin: 'checkstyle'
checkstyle {
ignoreFailures = false
configFile = rootProject.file('codequality/checkstyle.xml')
}

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "net.saliman:gradle-cobertura-plugin:2.0.0"
}
}
apply plugin: 'cobertura'

No source code preview for a file in a report in 2.2.0-SNAPSHOT

I was playing with 2.2.0-SNAPSHOT and in the report instead of code listing with the coverage I see:

Unable to locate info/solidsoft/gradle/pitest/PitestPlugin.groovy. Have you specified the source directory?

It worked fine with 2.1.0. Is it required to configure any additional parameter in build.gradle?

Gradle 1.9. The plain Groovy project. I can provide a small project to reproduce this issue if needed.

gradle+cobertura+grails=no bueno

The top of my build.gradle looks like this:

apply plugin: 'grails'
apply plugin: 'cobertura'

When I run "gradlew tasks" (or anything else), it fails like this:

> Cannot add task ':check' as a task with that name already exists.

So these two are stepping on each others' toes. How can I fix this?

Plugin can't find Groovy source

The cobertura-plugin can generate coverage reports for projects that have Groovy code, but the details of Groovy classes are missing from the reports because only Java source code is included in the cobertura's source directory set.

All tasks of type test become dependencies of the cobertura task regardless of the coverageTestTasks value.

Hello,

I am using the 2.2.0 version of the plugin and have found that all of my tasks of type Test are dependencies of the cobertura task regardless of the coverageTestTasks setting. I have the following:

    task integration(type: Test) {
        testClassesDir = sourceSets.integration.output.classesDir
        classpath += sourceSets.integration.runtimeClasspath
    }

    cobertura {
        coverageFormats = ["xml", "html"]

        coverageTestTasks {
            project.tasks.withType(Test).matching {
                it.name.contains("test")
            }
        }
    }

    println cobertura.getCoverageTestTasks()

This prints out "[task ':my-project:test']". I would expect that only "test" should be run prior to cobertura but when I list the task dependencies using gradle tasks --all I see the following:

Other tasks
-----------
cobertura - Run tests and generate Cobertura coverage reports. [classes, integrationClasses, test, testClasses,
    coberturaReport - Generate Cobertura reports after tests finish.
    integration

Is this a bug? I can get around it by doing the following:

project.tasks.getByName("cobertura").dependsOn -= integration

Thanks.

Task dependencies are limited to tasks in the graph at apply time

When the cobertura plugin is applied, certain task dependencies are set up, but it only uses tasks in the graph at that moment, which means that tasks added later, such as in child projects may not be added properly.

For example, if a project uses Groovy, but not Java, and if the cobertura plugin is added ahead of the groovy plugin, the groovy test task my not be set up properly.

configuration 'testRuntime' declares a dependency on configuration 'default' which is not declared in the module descriptor for net.sourceforge.cobertura:cobertura:2.0.3

I was using the gradle-cobertura-plugin for a while without issues. However, today it started failing with the following error

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not resolve all dependencies for configuration ':testRuntime'.

    Module version misc:myproject:1.0-SNAPSHOT, configuration 'testRuntime' declares a dependency on configuration 'default' which is not declared in the module descriptor for net.sourceforge.cobertura:cobertura:2.0.3

and the snippet of configuration which I use is the following

buildscript {  
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "net.saliman:gradle-cobertura-plugin:1.2.0"
    }
}
apply plugin: 'java'
apply plugin: 'cobertura'

cobertura {
    cobertura.coverageIgnoreTrivial = true
    coverageFormats = ['xml', 'html']
    cobertura.coverageExcludes = ['.*DTO.*']
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile 'com.h2database:h2:1.3.164'
    testCompile group: 'org', name: 'mockachino', version: '0.6.1', configuration: 'runtime'
}

The closest issue which came up from web is this http://play.lighthouseapp.com/projects/82401-play-20/tickets/779-publish-local-creates-invalid-ivy-file which seem to indicate that the dependency inside the plugin needs to be changed, which I am not sure.

Can you please advise on how to fix this?

Add coverageFormats option to README

Hi,

please add the coverageFormats option to the README file.
Maybe there are more options missing in the documentation.

Thanks.

Best regards

Roland

Unable to instrument file

I am having problems getting the plugin to work. The Jacoco plugin works fine, but I can't get Cobertura to work.

Here is what I added in build.gradle (using the 2.0 version of the Gradle wrapper and running under Java 8):

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'net.saliman:gradle-cobertura-plugin:2.2.4'
        classpath 'org.gradle.api.plugins:gradle-nexus-plugin:0.7'
    }
}
apply plugin: 'cobertura'

and here is the error I get. It is repeated for every file it tries to instrument.

C:\Prj\seerapi-client-java>gradlew clean cobertura
:clean
:coberturaReport UP-TO-DATE
:compileJava
:processResources UP-TO-DATE
:classes
:instrument
Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Unable to instrument file C:\Prj\seerapi-client-java\build\instrumented_classes\com\imsweb\seerapi\client\cs\CsCodeValidity.class
java.lang.IllegalArgumentException
        at org.objectweb.asm.ClassReader.<init>(Unknown Source)
        at org.objectweb.asm.ClassReader.<init>(Unknown Source)
        at org.objectweb.asm.ClassReader.<init>(Unknown Source)
        at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:147)
        at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121)
        at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234)
        at net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:298)
        at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:307)
        at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
        at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
        at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
        at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
        at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
        at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
        at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:399)

Cobertura 2.0.3 with JDK 1.7.0.40 failed to instrument classes

I am trying to run cobertura through ant, using jdk 7. but getting exception while instrumentation.
it was working fine with previous version of cobertura 1.5, with jdk 6.

currently i just upgraded jdk and cobertura.

exception is -

[cobertura-instrument] WARN instrumentClass, Unable to instrument file C:\MyCodeBase\Sample.class
[cobertura-instrument] java.lang.IncompatibleClassChangeError: net/sourceforge/c
obertura/instrument/pass1/DetectIgnoredCodeClassVisitor
[cobertura-instrument] at net.sourceforge.cobertura.instrument.CoberturaInstrum
enter.instrumentClass(CoberturaInstrumenter.java:149)
[cobertura-instrument] at net.sourceforge.cobertura.instrument.CoberturaInstrum
enter.instrumentClass(CoberturaInstrumenter.java:121)
[cobertura-instrument] at net.sourceforge.cobertura.instrument.CoberturaInstrum
enter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234)
[cobertura-instrument] at net.sourceforge.cobertura.instrument.Main.addInstrume
ntationToSingleClass(Main.java:298)
[cobertura-instrument] at net.sourceforge.cobertura.instrument.Main.addInstrume
ntation(Main.java:307)
[cobertura-instrument] at net.sourceforge.cobertura.instrument.Main.parseArgume
nts(Main.java:399)
[cobertura-instrument] at net.sourceforge.cobertura.instrument.Main.main(Main.j
ava:421)

Support generating coverage reports for a multiproject build where tests are isolated into a single project

I'm searching for a gradle cobertura plugin that supports my scenario: I have a multiproject where several projects contains some logically related contents and a single project that provides tests for all other projects.
The tests have been moved to a dedicate project cause I every project is backed by an eclipse project, and eclipse doesn't support separating tests from sources (within a single project). See http://tech.groups.yahoo.com/group/junit/message/22398

So launching gradle clean cobertura on a gradle multiproject structure like the following

.                                         //the multi-project
|-- build.gradle
|-- prj1                                  //the 'real' project
|   |-- build.gradle
|   `-- src
|       `-- main
|           `-- groovy
|               `-- Foo.groovy
|-- settings.gradle
`-- testprj                              //the test project
    |-- build.gradle
    `-- src
        `-- test
            `-- groovy
                `-- FooTest.groovy      //tests for Foo.groovy

I have the following problems:

  1. trying to see source contents on prj1 the report complains Unable to locate Foo.groovy. Have you specified the source directory?
  2. no coverage data available for cross-project tests (coverage is 0%)
  3. on testprj the coverage report is empty

Screenshot-Coverage Report - Google Chrome

I've uploaded an archive with the complete multiproject test case.

UPDATE: I've filed a similar issue to other gradle-cobertura plugins... is there any change to join your forces and provide a unified, comprehensive plugin that supports even my scenario?

use getClassesDirs instead of project.sourceSets.main.output.classesDir.path in InstrumentTask

use getClassesDirs instead of project.sourceSets.main.output.classesDir.path in InstrumentTask

I want change cobertura.coverageDirs in project configuration to point to another project like

cobertura.coverageDirs = [ project(':xxxxx').sourceSets.main.output.classesDir.path ]

You don't use getClassesDirs or cobertura.coverageDirs in the task InstrumentTask.
Maybe this can fix my problem.

I find a tempory solution

instrument.doFirst {
    project.copy {
project.files(project(':xxxxx').sourceSets.main.output.classesDir.path).each { 
            File f -> from f
        }
        into "${project.buildDir}/instrumented_classes"
    }
}   

Thanks.

Cobertura plugin causes user code to be executed, not just inspected

See USERCLASS in this jstack trace.

    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:605)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:333)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:307)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:645)
    at USERCLASS.<clinit>(USERCLASS.java:39)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at net.sourceforge.cobertura.instrument.CoberturaClassWriter.getCommonSuperClass(CoberturaClassWriter.java:32)
    at org.objectweb.asm.ClassWriter.a(Unknown Source)
    at org.objectweb.asm.Frame.a(Unknown Source)
    at org.objectweb.asm.Frame.a(Unknown Source)
    at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
    at org.objectweb.asm.MethodVisitor.visitMaxs(Unknown Source)
    at org.objectweb.asm.util.CheckMethodAdapter.visitMaxs(Unknown Source)
    at org.objectweb.asm.MethodVisitor.visitMaxs(Unknown Source)
    at org.objectweb.asm.MethodVisitor.visitMaxs(Unknown Source)
    at org.objectweb.asm.commons.LocalVariablesSorter.visitMaxs(Unknown Source)
    at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
    at org.objectweb.asm.util.CheckMethodAdapter$1.visitEnd(Unknown Source)
    at org.objectweb.asm.MethodVisitor.visitEnd(Unknown Source)
    at org.objectweb.asm.util.CheckMethodAdapter.visitEnd(Unknown Source)
    at org.objectweb.asm.ClassReader.b(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:205)
    at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121)
    at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234)
    at net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:298)
    at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:307)
    at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
    at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
    at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
    at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
    at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
    at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
    at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:399)
    at net.sourceforge.cobertura.instrument.Main.main(Main.java:421)

Adding tests to the project - encountering odd behaviour with latest pull

Hi,

I'm in the process of writing a load of unit tests for this project (I just love writing UTs, and it's a good way to learn).

I'd written a complete set of tests for most classes, and today I pulled the latest changes to my repo. After merging, I'm encountering a failure, which is indicating odd behaviour - it might be correct, but I wanted to check before re-doing the tests.

The test is as follows:

Define a project
Pass it into the constructor of CoberturaExtension
test the correct coverageSourceDirs are set, based on the language plugin

Before the change, a plain project had 1 coverageSourceDir, for java, which is correct.
A project with groovy applied had 2, while a project with groovy and scala applied had 3

after the change the extra coverageSourceDirs are not set - only the java one is present.

Is this intended behaviour, or have I mis-understood the purpose of the class?

Thanks

Jim

Cobertura Gradle Powermock Issue

Hi,

When we use power mock with gradle, gradle-cobetura-plugin does not generate the coverage report for the tests with power mock. However tests with out power mock is shown in the coverage report properly even-though they are in the same project.

Please check the following sample code I have written to recreate the issue.

https://github.com/lpambagoda/cobertura-gradle-powermock-issue

I have tested this with gradle 1.7 to 1.10 with gradle-cobetura-plugin 2.2.2.

There was a similar issue reported for maven as well. However that issue is fixed now.

http://www.jsfblog.info/2010/02/cobertura-code-coverage-with-maven-and-powermock/

Best Regards
Lasantha

Integration test

I'm using jettyRun to execute my webapp on a container to execute some integration test on it.

But the instrumented classes are not used by jetty.
SO the cobertura report doesn't include execution made using integration tests

Please add option for file encoding

Hi,

we have some projects with non-UTF-8 source encoding.

It would be great if you could provide an option to specify the character encoding of files.

Thanks.

Best regards

Roland

Cobertura and gradle-cobertura-plugin dont work with gradle 2.0 and java 8

I've working on a project using gradle 2.0 and java8. The current gradle-cobertur-plugin does not work with gradle 2.0 as its using alot of gradle methods deprecated as of gradle-1.12 and removed in gradle-2.0.

I switched to gradle 1.8 but Cobertura is unable to cover the unit tests as its failing due to instrumentation errors I'm guessing -> java.lang.VerifyError: Expecting a stackmap frame at branch target 185.

Cannot get this to work!!

Getting the following error using just the vanilla build.gradle file:
=== build.gradle ===
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "net.saliman:gradle-cobertura-plugin:1.1.2"
}
}
apply plugin: 'cobertura'
=== build.gradle ===

==== ERROR: =====

  • What went wrong:
    Could not resolve all dependencies for configuration ':testRuntime'.

    Could not find net.sourceforge.cobertura:cobertura:1.9.4.1.
    Required by:
    :cover-code:unspecified

Any ideas why this is happening?

Stack Trace during instrument (Groovy Project)

Using version of plugin resolved to: net.saliman:gradle-cobertura-plugin:2.0.0

With gradle --verson outputing:


Gradle 1.7

Build time: 2013-08-06 11:19:56 UTC
Build number: none
Revision: 9a7199efaf72c620b33f9767874f0ebced135d83

Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.6.0_21 (Sun Microsystems Inc. 17.0-b17)
OS: Windows 7 6.1 amd64

Every time I run the cobertura task gradle prints out the following stacktrace during instrument. Cobertura seems to successfully generate a code coverage report, so perhaps this is just noise bubbling up form cobertura, but it might have something to do with the inability to link to groovy source. It claims that while instrumenting class A it cannot find class B. My code is such that class A imports class B and uses it as an input to a method.

Note: I've redacted the package and class name of my classes involved here as I'm using this plugin in a build for a tool I'm writing for my employer.

java.lang.RuntimeException: java.lang.ClassNotFoundException: [CLASSNAME REDATCED: depended on object]
at net.sourceforge.cobertura.instrument.CoberturaClassWriter.getCommonSuperClass(CoberturaClassWriter.java:35)
at org.objectweb.asm.ClassWriter.a(Unknown Source)
at org.objectweb.asm.Frame.a(Unknown Source)
at org.objectweb.asm.Frame.a(Unknown Source)
at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
at org.objectweb.asm.MethodVisitor.visitMaxs(Unknown Source)
at org.objectweb.asm.util.CheckMethodAdapter.visitMaxs(Unknown Source)
at org.objectweb.asm.MethodVisitor.visitMaxs(Unknown Source)
at org.objectweb.asm.commons.LocalVariablesSorter.visitMaxs(Unknown Source)
at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
at org.objectweb.asm.util.CheckMethodAdapter$1.visitEnd(Unknown Source)
at org.objectweb.asm.MethodVisitor.visitEnd(Unknown Source)
at org.objectweb.asm.util.CheckMethodAdapter.visitEnd(Unknown Source)
at org.objectweb.asm.ClassReader.b(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:205)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234)
at net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:298)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:307)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:316)
at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:399)
at net.sourceforge.cobertura.instrument.Main.main(Main.java:421)
at net.saliman.gradle.plugin.cobertura.CoberturaRunner.instrument(CoberturaRunner.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.invoke(PojoMetaMethodSite.java:189)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at net.saliman.gradle.plugin.cobertura.InstrumentTask.instrument(InstrumentTask.groovy:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1047)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:877)
at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:248)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:136)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
at net.saliman.gradle.plugin.cobertura.InstrumentTask_Decorated.invokeMethod(Unknown Source)
at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1047)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:877)
at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:248)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:136)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
at net.saliman.gradle.plugin.cobertura.InstrumentTask_Decorated.invokeMethod(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:220)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:213)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:202)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:530)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:513)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:286)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTaskWithCacheLock(AbstractTaskPlanExecutor.java:58)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:47)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$1.run(DefaultTaskPlanExecutor.java:33)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:214)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:276)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:142)
at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:78)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:31)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:89)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:48)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.Main.main(Main.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
Caused by: java.lang.ClassNotFoundException: [CLASSNAME REDATCED: depended on object]
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at net.sourceforge.cobertura.instrument.CoberturaClassWriter.getCommonSuperClass(CoberturaClassWriter.java:32)
... 123 more

Groovy method causes unrelated coverage info to disappear

I have a codebase that we recently migrated from maven to gradle. One of the things we noticed is that a file which should have 90%+ coverage now has 20% coverage. Not only that, but the covered lines were nonsensical (in the middle of the a method with no other coverage, etc).

I trimmed it down to the smallest test case I could. I don't think this is the only issue in that file, but it's a start:

public class TestClass {
    // comment out this method to fix coverage
    public BigDecimal unusedMethod() {
        return usedMethod()
    }

    public BigDecimal usedMethod() {
        println 'Definitely reached!'
        1.0
    }

    public void unrelatedMethod() {
        println 'Unrelated method also reached'
    }
}

Please check out the repo https://github.com/syncsynchalt/cobertura-groovy-gradle-testcase and build with ./gradlew cobertura. You should see 0% coverage of the file, which should be 75% instead. If you comment out unusedMethod then it climbs to 100%.

Make the instrument's task up-to-date check depend on coberturaVersion

We recently encountered an issue after taking the following steps:

  • set the coberturaVersion manually to a version <= 1.9.3
  • run the cobertura task: all is ok
  • change the coberturaVersion to a version >= 1.9.4 and run the cobertura task again

You'll end up with the following issue: cobertura/cobertura#171

As pointed out in this issue's discussion, removing and re-generating the instrumented classes solves the issue.

In order not to use different cobertura versions for instrumentation and at runtime, the instrument task's inputs should include the coberturaVersion property so that it's not considered up-to-date anymore and re-runs the instrumentation when the cobertura version changes.

Exclude instrumenting some packages

Hi, I didn't find a mailing list so I had to raise an issue... sorry.
I am using this but I don't know how to exclude some package from being instrumented.
Please let me know how can I do that.

By the way I tried this and it din't work:

cobertura {
coverageExcludes = ['com.others.*']
}

Thank you.

Cobertura reports and coverage checks are inaccurate when tests don't run

When users request a report, we start with a fresh .ser file every time to get an accurate report. But tests may be up to date, which means they won't run, and Cobertura will report coverage incorrectly.

If users want a coverage report, we need to force all the tests to no longer be up to date so they will be forced to run so that reports and coverage checks will be accurate.

The plugin should have no effect on a test's up-to-date status when coverage reports are not requested by the user.

How do I set auxClasspath?

I've got a situation where Cobertura seems to be working, but a bunch of errors are generated about not being able to find some classes. Google suggests that the solution is setting the auxiliary classpath to point to the locations of the class files in question. I had hoped that I would set the auxClasspath or auxiliaryClasspath value like so:

cobertura {
    coverageFormats = [ "xml" ]
    auxiliaryClasspath = project.sourceSets.main.output.classesDir.path + ":" + project.sourceSets.main.compileClasspath.getAsPath()
}

But I've had no luck so far.

Deprecated dynamic property: "auxClasspath" on "net.saliman.gradle.plugin.cobertura.CoberturaExtension_Decorated@65941543"

Deprecated dynamic property: "auxiliaryClasspath" on "net.saliman.gradle.plugin.cobertura.CoberturaExtension_Decorated@2961ae44"

Am I going down the wrong road here?

Thanks.

Failed to find xalan jar

Put on buildscript classpath.

Using mavenCentral() only.

Could not resolve all dependencies for configuration ':classpath'.
Could not download artifact 'xalan:xalan:2.6.0@jar'
> Artifact 'xalan:xalan:2.6.0@jar' not found.

Cobertura runs all tasks of Type Test?

Hi. I have src/test and src/intTest (integration tests) in the same project. The default test task runs tests in src/test, of course. And I have an intTest task of Type Test that runs on demand integration tests, which happen to be in src/intTest.

Does cobertura run all tasks of Type Test? It appears that way. Is there a way to disable that an specify which tasks it should run in?

Thank you.

Not able to download version 1.2.0 from maven central

code:
buildscript { repositories { mavenCentral() } dependencies { classpath "net.saliman:gradle-cobertura-plugin:1.2.0" } }

error that I get:
Could not resolve all dependencies for configuration ':classpath' Could not find net.saliman:gradle-cobertura-plugin:1.2.0.

Lack of versatility in the task setup

The way registerTaskFixupListener at https://github.com/stevesaliman/gradle-cobertura-plugin/blob/master/src/main/groovy/net/saliman/gradle/plugin/cobertura/CoberturaPlugin.groovy#L118 is implemented prevents us from using this plugin as we would like.

First: A sub-module's "test" task DEPENDS on the test tasks of all other modules. This is weird, and should not be. I don't need to test any other module in order to generate a coverage report for one.

Second: I want to be able to generate a coverage report by just making a test depend on the instrumentation setup. The fixup code here means I can ONLY ever generate coverage if I invoke "cobertura", so I cannot do my standard trick of generating coverage for a run of a single test class using -Dtest.single

The plugin setup at https://github.com/eriwen/gradle-cobertura-plugin/blob/master/src/main/groovy/org/gradle/api/plugins/cobertura/CoberturaPlugin.groovy is much better in terms of setup:

  1. The cobertura-configure task modifies the classpath and system properties. This means that if a test task depends on a cobertura task (a decision I can make on the fly), then the setup is performed for that one instance.

  2. The cobertura task has an input serFile and an output serFile, which allows the gradle dependency/skip mechanism to be intelligent about whether cobertura needs rerunning or not.

Unfortunately there's a bug in that serFile handling, else I'd use that plugin. However, the essentially hardcoded task setup in this plugin pretty much prevents me from using it either. The sucky HTML report in JaCoCo annoys me enough that I'm not going to use that.

Of them all, I think your plugin has the greatest potential, and I'd strongly encourage you to look at this issue. Do we send you beers, pizzas or similar?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.