Cobertura

Related tags

cobertura
Overview

COBERTURA

Build Status

ABOUT

Cobertura is a free Java code coverage reporting tool. It is based on jcoverage 1.0.5. See the Cobertura web page and wiki for more details.

Since 2.0.0, Cobertura versions follow the Semantic versioning guidelines.

DOWNLOAD

You can download Cobertura from The Central Repository. That includes the distributions for stand-alone command line usage.

To use it as Maven dependency, you can use the following snippet:

<dependency>
    <groupId>net.sourceforge.cobertura</groupId>
    <artifactId>cobertura</artifactId>
    <version>2.1.1</version>
    <scope>test</scope>
</dependency>

COPYRIGHT

Code in the net.sourceforge.cobertura.javancss package is Copyright (C) 2000 Chr. Clemens Lee

See the included file "LICENSE.txt"

LICENSE

Cobertura is free software. Most of it is licensed under the GNU GPL, and you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Please review the file LICENSE.txt included in this distribution for further details. Parts of Cobertura are licensed under the Apache Software License, Version 1.1.

WARRANTY

Cobertura is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

CONVENTIONS

Before committing

  • check all tests pass
  • build the project, so that all code gets uniformly indented. A Maven plugin ensures this.

MAVEN MIGRATION NOTES

  • How do we get a good blame while all files were moved?

Use "git blame --follow" nameOfFile.java

Cobertura is built on Travis-CI.

Issues
  • ParseException JavaNCSS got an error while parsing the java file

    ParseException JavaNCSS got an error while parsing the java file

    In Cobertura 2.0.3, with gradle, parsing this code gives the below error. private ArrayList<String[][]> dUpdates = new ArrayList<String[][]>(); (...) for (String row[][] : dUpdates) { //<-- error here

    :generateCoberturaReport Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file net.sourceforge.cobertura.javancss.parser.ParseException: Encountered " ":" ": "" at line 417, column 30. Was expecting one of: "[" ... ";" ... "," ... "=" ...

        at net.sourceforge.cobertura.javancss.parser.JavaParser.generateParseException(JavaParser.java:11869)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.jj_consume_token(JavaParser.java:11730)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ForStatement(JavaParser.java:4292)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.Statement(JavaParser.java:3735)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.BlockStatement(JavaParser.java:3906)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.Block(JavaParser.java:3855)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.TryStatement(JavaParser.java:4534)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.Statement(JavaParser.java:3754)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.BlockStatement(JavaParser.java:3906)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.Block(JavaParser.java:3855)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.MethodDeclaration(JavaParser.java:1933)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ClassBodyDeclaration(JavaParser.java:1012)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ClassBody(JavaParser.java:874)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.UnmodifiedClassDeclaration(JavaParser.java:801)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ClassDeclaration(JavaParser.java:706)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.TypeDeclaration(JavaParser.java:555)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.CompilationUnit(JavaParser.java:303)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.parse(JavaParser.java:100)
        at net.sourceforge.cobertura.javancss.Javancss._measureSource(Javancss.java:192)
        at net.sourceforge.cobertura.javancss.Javancss._measureRoot(Javancss.java:268)
        at net.sourceforge.cobertura.javancss.Javancss.<init>(Javancss.java:346)
        at net.sourceforge.cobertura.reporting.ComplexityCalculator.getAccumlatedCCNForSource(ComplexityCalculator.java:105)
        at net.sourceforge.cobertura.reporting.ComplexityCalculator.getAccumlatedCCNForSingleFile(ComplexityCalculator.java:143)
        at net.sourceforge.cobertura.reporting.ComplexityCalculator.getCCNForSourceFileNameInternal(ComplexityCalculator.java:234)
        at net.sourceforge.cobertura.reporting.ComplexityCalculator.getCCNForPackageInternal(ComplexityCalculator.java:201)
        at net.sourceforge.cobertura.reporting.ComplexityCalculator.getCCNForProject(ComplexityCalculator.java:167)
        at net.sourceforge.cobertura.reporting.html.HTMLReport.generateTableRowForTotal(HTMLReport.java:603)
        at net.sourceforge.cobertura.reporting.html.HTMLReport.generateOverview(HTMLReport.java:287)
        at net.sourceforge.cobertura.reporting.html.HTMLReport.generateOverviews(HTMLReport.java:228)
        at net.sourceforge.cobertura.reporting.html.HTMLReport.<init>(HTMLReport.java:71)
        at net.sourceforge.cobertura.reporting.Main.parseArguments(Main.java:103)
        at net.sourceforge.cobertura.reporting.Main.main(Main.java:169)
        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.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.generateCoverageReport(CoberturaRunner.groovy:100)
        at net.saliman.gradle.plugin.cobertura.CoberturaRunner$generateCoverageReport.call(Unknown Source)
        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:128)
        at net.saliman.gradle.plugin.cobertura.GenerateReportTask.generateReports(GenerateReportTask.groovy:54)
        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.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
        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:533)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:516)
        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:289)
        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.process(DefaultTaskPlanExecutor.java:23)
        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.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:60)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:186)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:36)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:51)
        at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:155)
        at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
        at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
        at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)
    

    JavaNCSS got an error while parsing the java file C:(...)\SyncTaskData.java ParseException in STDINronize.getTarget(ColumnMapping.SWITCH_CODE) != null) Last useful checkpoint: "(...).SyncTaskData.update(Tuple,PreparedStatement,PreparedStatement,PreparedStatement)" Encountered " ":" ": "" at line 417, column 30 Was expecting one of: "[" ... ";" ... "," ... "=" ...

    Parsing Issue 
    opened by mapo-job 98
  • Error when using Java 8

    Error when using Java 8

    I'm trying to run Cobertura for Java 8 project. I get errors like

    java.lang.VerifyError: Expecting a stackmap frame at branch target 78

    Using -XX:-UseSplitVerifier does not help since I think it was dropped in Java 8.

    opened by ghost 26
  • Fix Java8 instrumentation exception due to use of ASM4 API version.

    Fix Java8 instrumentation exception due to use of ASM4 API version.

    Fix #248 exception at instrumentation phase. No special handling logic for new API version is needed.

    opened by vkovalchuk 21
  • ERROR - loadCoverageData

    ERROR - loadCoverageData

    Hi, I have downloaded the source code for Gameoflife application and trying to follow the steps indicated in the book that uses this application to show Code coverage in Jenkins + Maven. I am very new to cobertura, running mvn clean package cobertura:cobertura, I get a coverage with 0.0 everywhere in spite of the fact that around 50 tests are run. The output is :+1: INFO] --- cobertura-maven-plugin:2.6:cobertura (default-cli) @ gameoflife-web --- [INFO] Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file Report time: 188ms

    [ERROR] févr. 24, 2015 3:46:52 PM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler loadCoverageData INFO: Cobertura: Loaded information on 2 classes.

    [INFO] Cobertura Report generation was successful. [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] gameoflife ......................................... SUCCESS [ 13.773 s] [INFO] gameoflife-build ................................... SUCCESS [ 0.703 s] [INFO] gameoflife-core .................................... SUCCESS [ 6.612 s] [INFO] gameoflife-web ..................................... SUCCESS [ 10.741 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 38.523 s [INFO] Finished at: 2015-02-24T15:46:52+01:00 [INFO] Final Memory: 28M/247M [INFO] ------------------------------------------------------------------------ [Cobertura] Publishing Cobertura coverage report... Publishing Cobertura coverage results... Cobertura coverage report found. Code coverage enforcement failed for the following metrics: Packages's stability is 0.0 and set mininum stability is 95.0. Methods's stability is 0.0 and set mininum stability is 80.0. Lines's stability is 0.0 and set mininum stability is 75.0. Conditionals's stability is 0.0 and set mininum stability is 75.0. Setting Build to unstable. Build step 'Publish Cobertura Coverage Report' changed build result to UNSTABLE Recording test results Publishing Javadoc Finished: UNSTABLE

    I ran the same command in a terminal and getting the same output.

    Thanks for your help

    Maven 
    opened by eliassal 20
  • With 2.0.3 still seeing ClassNotFoundException in-spite of using --auxClasspath during instrumentation

    With 2.0.3 still seeing ClassNotFoundException in-spite of using --auxClasspath during instrumentation

    Command Line used :- C:\cobertura-2.0.3\cobertura-instrument.bat --auxClasspath "c:\Program Files (x86)\XX\OIU\CLI\oiucli-1.0.0-jar-with-dependencies" --datafile "c:\cc\SER\oiu_cli.ser" "c:\Program Files (x86)\XX\OIU\CLI"\oiucli-1.0.0-jar-with-dependencies\com

    Sep 13, 2013 1:25:01 AM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler loadCoverageData INFO: Cobertura: Loaded information on 40 classes. Sep 13, 2013 1:25:02 AM net.sourceforge.cobertura.coveragedata.TouchCollector registerClass SEVERE: Exception when registering class: com/xx/oiu/cli/OIUOption java.lang.ClassNotFoundException: com.xx.oiu.cli.OIUOption at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at net.sourceforge.cobertura.coveragedata.TouchCollector.registerClass(TouchCollector.java:80) at com.xx.oiu.cli.OIUOption.__cobertura_init(OIUOption.java) at com.xx.oiu.cli.OIUOption.(OIUOption.java) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) 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.parseArguments(Main.java:399) at net.sourceforge.cobertura.instrument.Main.main(Main.java:421)

    opened by wishabcd 19
  • using cobertura 2.0.3 fails with no coverage - fails in saveCoverageData

    using cobertura 2.0.3 fails with no coverage - fails in saveCoverageData

    Cobertura does not report coverage in Sonar for this project. I find the below error in jenkins log.

    Using Java7 and Cobertura 2.0.3

    [INFO] --- cobertura-maven-plugin:2.6:instrument (default-cli) @ domain-project ---[ERROR] Oct 29, 2013 4:23:53 PM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler saveCoverageData INFO: Cobertura: Saved information on 203 classes.

    [INFO] Instrumentation was successful. [INFO] NOT adding cobertura ser file to attached artifacts list.

    INFO] --- cobertura-maven-plugin:2.6:cobertura (default-cli) @ domain-payment --- [INFO] Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file

    [ERROR] Oct 29, 2013 4:37:20 PM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler loadCoverageData SEVERE: Cobertura: Error reading file /x/Mobile/projects/domain/domain-project/target/cobertura/cobertura.ser: null java.io.EOFException

    Maven bug 
    opened by maskbit 17
  • Cobertura 2.0.4 will create breaking changes to plugins

    Cobertura 2.0.4 will create breaking changes to plugins

    I saw in 1ssue 74 that there is a planned 2.0.4 release for this week.

    The Main classes for instrumentation, reporting, etc have changed names in this release, which will cause any code trying to access Cobertura classes, such as existing plugins, to break when 2.0.4 is released. It might be a good idea to restore those class names to Main. This is particularly useful for plugins that are not tied to a particular Cobertura version, such as the Gradle Cobertura plugin, which works with whatever version the user specifies.

    Also, if there is time, it would also be good if all of the main classes had main methods that wrapped "runner" methods that don't use system.exit. I fixed one of them in issue 98, but I wasn't able to get to the instrumentation class, the report generation class, etc.

    Thanks,

    Steve

    opened by stevesaliman 17
  • Fixes failing test cases and adds Java8 Lambdas and method references

    Fixes failing test cases and adds Java8 Lambdas and method references

    1. Fixed test problems by updating dependencies, deperacated APIs
    2. Updated latest javancss
    3. Added lambda and method references to the parser to support Java8
    opened by herenyi 16
  • NullPointerException in FindTouchPointsMethodAdapter.visitLineNumber

    NullPointerException in FindTouchPointsMethodAdapter.visitLineNumber

    Some of our classes throw NullPointerExceptions when cobertura tries to instrument those. This is the stacktrace:

    [cobertura-instrument] WARN   instrumentClass, Unable to instrument file /home/jenkins/jobs/Test Coverage/workspace/build/classes/path/to/package/AClass.class
    [cobertura-instrument] java.lang.NullPointerException
    [cobertura-instrument]  at java.util.LinkedList.addAll(LinkedList.java:269)
    [cobertura-instrument]  at java.util.LinkedList.addAll(LinkedList.java:247)
    [cobertura-instrument]  at java.util.LinkedList.<init>(LinkedList.java:98)
    [cobertura-instrument]  at net.sourceforge.cobertura.instrument.FindTouchPointsMethodAdapter.visitLineNumber(FindTouchPointsMethodAdapter.java:196)
    [cobertura-instrument]  at org.objectweb.asm.ClassReader.a(Unknown Source)
    [cobertura-instrument]  at org.objectweb.asm.ClassReader.b(Unknown Source)
    [cobertura-instrument]  at org.objectweb.asm.ClassReader.accept(Unknown Source)
    [cobertura-instrument]  at org.objectweb.asm.ClassReader.accept(Unknown Source)
    [cobertura-instrument]  at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:161)
    [cobertura-instrument]  at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121)
    [cobertura-instrument]  at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234)
    [cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:298)
    [cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:307)
    [cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:399)
    [cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.main(Main.java:421)
    

    We are using Cobertura 2.0.3 and we instrument the classes using the ant task.

    When more info is needed, I'm happy to provide it.

    Affects 2.1.1 
    opened by oosterholt 14
  • Primitive class parser problem

    Primitive class parser problem

    [ERROR] j·n 10, 2013 12:45:49 PM net.sourceforge.cobertura.coveragedata.Coverage DataFileHandler loadCoverageData INFO: Cobertura: Loaded information on 43 classes. net.sourceforge.cobertura.javancss.parser.ParseException: Encountered " "." ". " " at line 105, column 29. Was expecting: ")" ...

    for code

            if ((boolean.class).equals(fieldType.getRawType()) || (Boolean.class).equals(fieldType.getRawType()) && field.getAnnotation(SerializeAsNumber.class) != null) {
    

    but no error if i change code

            Class<?> primitive = boolean.class;
            if ((primitive).equals(fieldType.getRawType()) || (Boolean.class).equals(fieldType.getRawType()) && field.getAnnotation(SerializeAsNumber.class) != null) {
    
    
    opened by igieon 13
  • The link to access Cobertura Plugin at Maven it was broken

    The link to access Cobertura Plugin at Maven it was broken

    Hi, i've noticed that link it was broken. So i Just fixed to the correct one, 👍🏼 .

    opened by artsmandev 0
  • I hava a question. How to convert/transform Cobertura.xml(codecoverage report) to junit

    I hava a question. How to convert/transform Cobertura.xml(codecoverage report) to junit

    In NUnit , we can transform report to Junit. Is it possible in Cobertura ?If yes the how ?

    opened by Mitkari 0
  • cobertura-2.1.1 throws InvocationTargetException worked in cobertura-1.9.4.1

    cobertura-2.1.1 throws InvocationTargetException worked in cobertura-1.9.4.1

    Hi after attempting to upgrade to 2.1.1 I see this in my ant-task

    Null Test: Caused an ERROR null java.lang.reflect.InvocationTargetException Caused by: java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector

    It happens on this line of my code

    public abstract class BaseTest extends TestCase {
    
        **private static final Log log = Log.getLogger(BaseTest.class);**
    
    
    opened by sproket 0
  • When can we expect latest releases for Cobertura which is compatible with Java 8 and higher versions

    When can we expect latest releases for Cobertura which is compatible with Java 8 and higher versions

    Hi Team,

    We need to generate cobertura coverage report for few classes having Java 8 features. Cobertura Maven Plugin 2.7 or 2.6 versions are not compatible with Java 8 currently.

    So please let us know when can we expect latest releases for Cobertura which is compatible with Java 8 and higher versions.

    Thanks in Advance.

    opened by PriyankaKeer 3
  • Visual Studio Code Coverage file (.coverage) support

    Visual Studio Code Coverage file (.coverage) support

    Does cobertura support exporting code coverage report to visual studio code coverage files?

    opened by FluentGuru 0
  • Cobertura report is not getting generated for few classes having java 8, though few classes containing same Java 8 is getting included in reports

    Cobertura report is not getting generated for few classes having java 8, though few classes containing same Java 8 is getting included in reports

    Cobertura report is not getting generated for few classes having java 8, though few classes containing same Java 8 is getting included in reports

    We are using 2.7 version cobertura. tried with 2.6 version but still the same error. Also tried with asm 5.0.3 dependency inside cobertura. But facing issue in some classes where it is giving below error. The report generated is not including the classes which are having this error. Can anyone pls suggest some resolution..?

    net.sourceforge.cobertura.javancss.parser.ParseException: Encountered " ">" "> "" at line 242, column 48. Was expecting one of: "assert" ... "boolean" ... "byte" ... "char" ... "double" ... "enum" ... "false" ... "float" ... "int" ... "long" ... "new" ... "null" ... "short" ... "super" ... "this" ... "true" ... "void" ... <INTEGER_LITERAL> ... <FLOATING_POINT_LITERAL> ... <CHARACTER_LITERAL> ... <STRING_LITERAL> ... ... "(" ... "!" ... "~" ... "++" ... "--" ... "+" ... "-" ...

        at net.sourceforge.cobertura.javancss.parser.JavaParser.generateParseException(JavaParser.java:10490)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.jj_consume_token(JavaParser.java:10366)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.UnaryExpression(JavaParser.java:3175)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.MultiplicativeExpression(JavaParser.java:3090)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.AdditiveExpression(JavaParser.java:3085)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ShiftExpression(JavaParser.java:3027)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.RelationalExpression(JavaParser.java:2990)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.InstanceOfExpression(JavaParser.java:2977)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.AssigmentExpression(JavaParser.java:2959)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.EqualityExpression(JavaParser.java:2886)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.AndExpression(JavaParser.java:2860)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ExclusiveOrExpression(JavaParser.java:2843)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.InclusiveOrExpression(JavaParser.java:2826)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ConditionalAndExpression(JavaParser.java:2808)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ConditionalOrExpression(JavaParser.java:2790)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ConditionalExpression(JavaParser.java:2774)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.Expression(JavaParser.java:2718)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ArgumentList(JavaParser.java:3620)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.Arguments(JavaParser.java:3610)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.PrimarySuffix(JavaParser.java:3511)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.PrimaryExpression(JavaParser.java:3384)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.StatementExpression(JavaParser.java:4070)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.Statement(JavaParser.java:3795)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.BlockStatement(JavaParser.java:3984)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.Block(JavaParser.java:3934)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.MethodDeclaration(JavaParser.java:1987)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ClassBodyDeclaration(JavaParser.java:1039)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ClassBody(JavaParser.java:898)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.UnmodifiedClassDeclaration(JavaParser.java:824)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.ClassDeclaration(JavaParser.java:728)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.TypeDeclaration(JavaParser.java:575)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.CompilationUnit(JavaParser.java:318)
        at net.sourceforge.cobertura.javancss.parser.JavaParser.parse(JavaParser.java:100)
        at net.sourceforge.cobertura.javancss.Javancss._measureSource(Javancss.java:192)
        at net.sourceforge.cobertura.javancss.Javancss._measureRoot(Javancss.java:268)
        at net.sourceforge.cobertura.javancss.Javancss.<init>(Javancss.java:347)
        at net.sourceforge.cobertura.javancss.JavancssFactory.newInstance(JavancssFactory.java:40)
        at net.sourceforge.cobertura.reporting.ComplexityCalculator.getFunctionMetricsForSingleFile(ComplexityCalculator.java:243)
        at net.sourceforge.cobertura.reporting.ComplexityCalculator.getAccumlatedCCNForSingleFile(ComplexityCalculator.java:143)
        at net.sourceforge.cobertura.reporting.ComplexityCalculator.getCCNForSourceFileNameInternal(ComplexityCalculator.java:273)
        at net.sourceforge.cobertura.reporting.ComplexityCalculator.getCCNForPackageInternal(ComplexityCalculator.java:208)
        at net.sourceforge.cobertura.reporting.ComplexityCalculator.getCCNForProject(ComplexityCalculator.java:174)
        at net.sourceforge.cobertura.reporting.html.HTMLReport.generateTableRowForTotal(HTMLReport.java:606)
        at net.sourceforge.cobertura.reporting.html.HTMLReport.generateOverview(HTMLReport.java:290)
        at net.sourceforge.cobertura.reporting.html.HTMLReport.generateOverviews(HTMLReport.java:231)
        at net.sourceforge.cobertura.reporting.html.HTMLReport.<init>(HTMLReport.java:74)
        at net.sourceforge.cobertura.reporting.html.HTMLReportFormatStrategy.save(HTMLReportFormatStrategy.java:18)
        at net.sourceforge.cobertura.reporting.NativeReport.export(NativeReport.java:31)
        at net.sourceforge.cobertura.reporting.CompositeReport.export(CompositeReport.java:19)
        at net.sourceforge.cobertura.reporting.ReportMain.parseArgumentsAndReport(ReportMain.java:91)
        at net.sourceforge.cobertura.reporting.ReportMain.generateReport(ReportMain.java:141)
        at net.sourceforge.cobertura.reporting.ReportMain.main(ReportMain.java:151)
    
    opened by PriyankaKeer 0
  • Update README.md

    Update README.md

    Changed http:// to https:// where necessary.

    opened by B4Art 0
  • Method partially covered but missing from Metrics and lines aren't highlighted in File(s) sections

    Method partially covered but missing from Metrics and lines aren't highlighted in File(s) sections

    I have an Azure Function written in C#.

    It has a "Run" method. Within the Run method, it also calls Task.Run (run lambda functions concurrently) twice.

    The cobertura's metrics section for the class doesn't list the Run method in the table. Instead it is showing only a row for each the two Task.Run lambda functions but it shows them as "<Run". In the File(s) section, there is no visual coverage for the Run method, only the lambda Functions. The Summary section's covered line count seems correct for real coverage despite the error with the Files(s) visual coverage report.

    opened by Camios 0
  • Cobertura 2.7 + Tycho JDT <= 0.15.0 causes lines to be not covered

    Cobertura 2.7 + Tycho JDT <= 0.15.0 causes lines to be not covered

    Hello, guys. I've noticed that using specific chained if/else causes lines to not be covered by Cobertura 2.7 if compiled with Tycho JDT compiler version <= 0.15.0, on Maven.

    If I use JAVAC instead or use Tycho JDT >= 0.16.0 it works and I get those lines covered again.

    The configuration to reproduce the problem is:

    • Maven 3.3.9;
    • Java JDK 1.7.0_80 (64b);
    • Cobertura 2.7;
    • Junit 4.12;
    • Tycho compiler JDT 0.15.0 (or less);
    • Maven Compiler 3.8.1;
    • Surefire 3.0.0-M4.

    The POM.xml

    <dependencies>
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
    
    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.1</version>
          <configuration>
            <compilerId>jdt</compilerId> <!-- this CAUSES the problem -->
            <!-- <compilerId>javac</compilerId> --> <!-- this SOLVES the problem -->
            <encoding>ISO-8859-1</encoding>
            <fork>false</fork>
            <source>1.7</source>
            <target>1.7</target>
            <optimize>true</optimize>
            <showWarnings>false</showWarnings>
            <proc>none</proc>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>org.eclipse.tycho</groupId>
              <artifactId>tycho-compiler-jdt</artifactId>
              <version>0.15.0</version> <!-- or less, CAUSES the problem -->
              <!-- <version>0.16.0</version> --> <!-- or greater, SOLVES the problem -->
              <scope>compile</scope>
            </dependency>
          </dependencies>
        </plugin> 
        
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.0.0-M4</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>cobertura-maven-plugin</artifactId>
          <version>2.7</version>
          <configuration>
            <formats>
              <format>html</format>
            </formats>
          </configuration>
        </plugin>
      </plugins>
    </build>
    

    The Java code [note the a) if/else chained condition, b) use of a local variable and c) how the return statement is written]:

    public class MyValidator {
        public Double methodWithChainedCondition(String arg) throws Exception{
            Double result = 0d;     
            if (arg.length() > 0) {
                if (arg.equals("ONE")) {
                    result = 1.1;
                }
            } else {
                result = 2.0;
            }       
            return result;
        }
    
        public Boolean methodCoveredByTests(int arg) {
            return arg!=0 && arg%2==0;
        }
    }
    

    Junit test:

    public class MyValidatorTest {
      MyValidator classUnderTest = new MyValidator();
      
      @Test
      public void testMethodCoveredByUnitTests_EVEN() {
        Assert.assertTrue( classUnderTest.methodCoveredByTests(2) );
        Assert.assertTrue( classUnderTest.methodCoveredByTests(6) );
      }
      
      @Test
      public void testMethodCoveredByUnitTests_ODD() {
        Assert.assertFalse( classUnderTest.methodCoveredByTests(1) );
        Assert.assertFalse( classUnderTest.methodCoveredByTests(5) );
      }
    }
    

    Result with JDT: cobertura with bug

    Result with JAVAC: cobertura bug fixed

    Note:

    • When I used JDK8 with Maven 3.6.1, I coudn't reproduce the bug in all the times I'd built the project.

    Some companies still use that compiler, so I hope this feedback could be helpful to you to find out the bug. Thanks.

    opened by mattqmello 0
  • SomeUtilsClass does not appear in the cobertura report

    SomeUtilsClass does not appear in the cobertura report

    I have ClassA, ClassB and SomeUtilsClass in my package ../utils

    The cobertura report for package ../utils has the required informations for ClassA and ClassB. However, SomeUtilsClass does not appear in coverage report as if this class didn't exist in the package ../utils. Sample SomeUtilsClass : public class SomeUtilsClass {

    private SomeUtilsClass() {
        // Private Constructor :  will never be initialized.
    }
    
    private static void setFieldValue(BusinessObject businessObj, Field field, String propertyName, Object fieldValue) {
        boolean isPrivate = !field.isAccessible();
        try {
            if (isPrivate) {
                field.setAccessible(true);
            }
    
            Class<?> fieldType = field.getType();
            if (fieldType.isAssignableFrom(fieldValue.getClass())) {
                field.set(businessObj, fieldValue);
            } else {
                if (fieldType.isPrimitive()) {
                    someMethodeB(params);
                } else if (fieldType.isEnum()) {
                    field.set(params);
                } else if (fieldValue instanceof String) {
                    someMethodeA(params);
                } else {
                    throw new IllegalArgumentException("Type value is not supported [" + fieldValue.getClass() + "]");
                }
            }
        } catch (SecurityException e) {
            logger.warn("Error while setting the accessibility of the property '{}' in setProperties.", field.getName(), e);
        } catch (IllegalArgumentException | IllegalAccessException e) {
            logger.warn("Error while loading the property '{}' in setProperties.", field.getName(), e);
        } finally {
            if (isPrivate) {
                field.setAccessible(false);
            }
        }
    }
    

    }

    Can you please help me with that?? thanks

    opened by ibramouka 0
Owner
Cobertura
Cobertura