cobertura

Running code coverage with Cobertura and Jacoco

前提是你 提交于 2020-01-01 06:26:16
问题 I have a bit of a problem getting code coverage reports for both Integration Tests and Unit Tests in Sonar for a Maven Plugin project (which uses invoker plugin for the integration tests). I can't use the default Jacoco coverage tool for the unit tests, as these use Powermock, which results in 0% coverage for classes using that. On the other hand, I can't find a reliable way to get results for the Groovy-based integration tests without using Jacoco. So what I need is for Cobertura to produce

Running code coverage with Cobertura and Jacoco

≡放荡痞女 提交于 2020-01-01 06:26:05
问题 I have a bit of a problem getting code coverage reports for both Integration Tests and Unit Tests in Sonar for a Maven Plugin project (which uses invoker plugin for the integration tests). I can't use the default Jacoco coverage tool for the unit tests, as these use Powermock, which results in 0% coverage for classes using that. On the other hand, I can't find a reliable way to get results for the Groovy-based integration tests without using Jacoco. So what I need is for Cobertura to produce

How to get Cobertura to fail M2 build for low code coverage

 ̄綄美尐妖づ 提交于 2019-12-30 04:31:06
问题 I'm trying to configure my WAR project build to fail if the line or branch coverage is below given thresholds. I've been using the configuration provided on page 455 of the excellent book Java Power Tools, but with no success. Here's the relevant snippet of my project's Maven 2 POM: <build> ... <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.2</version> <configuration> <check> <!-- Per-class thresholds --> <lineRate>80<

Cobertura on Tomcat

痞子三分冷 提交于 2019-12-29 05:27:06
问题 I'm trying to apply code coverage using Cobertura. The app is deployed in Tomcat 5, but when I instrument the .class files, the app stops working. This are my steps: Compile the app (This run in tomcat) Instrument the class files. D:\test\cobertura-1.9.4.1\cobertura-instrument.bat --destination D:\test\instrument D:\src\path_to_app\main\target\webapp Overwrite the class files of D:\src\path_to_app\main\target\webapp with the instrumented class files in D:\test\instrument . Deploy the app in

What are the differences between the three methods of code coverage analysis?

一笑奈何 提交于 2019-12-29 03:37:13
问题 This sonar page basically lists the various methods employed by different code coverage analysis tools: Source code instrumentation (Used by Clover) Offline byte code instrumentation (Used by Cobertura) On-the-fly byte code instrumentation (Used by Jacoco) What are these three methods and which one is the most efficient and why?If the answer to the question of efficiency is "it depends" , then please explain why? 回答1: Source code instrumentation consists in adding instructions to the source

Branch coverage with JUnit and Mockito

谁说我不能喝 提交于 2019-12-25 07:27:24
问题 I am writing a test case using JUnit API for a method. I've covered all the scenarios but the one that is giving me a hard time is in the if block. When I hover over this line the Cobertura states 50% 50% for each condition but I am not exactly sure how to get this covered. Method under test: protected boolean isDateWithinTimelineRange( Calendar date, ServiceContext ctx ) { Calendar end = (Calendar)ctx.getParameter( ServiceConstants.TIMELINE_END ); Calendar start = (Calendar)ctx.getParameter(

logger.isDebugEnabled() is killing my code coverage. I'm planning to exclude it while running cobertura

孤街浪徒 提交于 2019-12-25 02:18:13
问题 I tried by adding in org.slf4j.* in cobertura.exclude. but there is no use. my buildfile require 'buildr/java/cobertura' require 'buildr/scala' require 'buildr/myProject' ..... ..... compile.options.other = %w(-encoding UTF-8) cobertura.exclude= 'org.slf4j.*' ..... ..... Please suggest how to proceed. Thank you in advance 回答1: The issue is that cobertura.exclude is to exclude files/classes in your project from being instrumented. What you want to use is cobertura.ignore , e.g., cobertura

Excluding some classes from the cobertura report doesn't work

霸气de小男生 提交于 2019-12-24 10:39:20
问题 I tried to remove some classes from the cobertura report as <target name="voldemort-instrument" description="Instrument Voldemort Classes"> <mkdir dir="${voldemort.instrumented.dir}" /> <cobertura-instrument todir="${voldemort.instrumented.dir}" datafile="${cobertura.instrument.file}"> <classpath refid="tools-classpath" /> <ignore regex=".*\.xsd" /> <fileset dir="${voldemort.dist.dir}/classes"> <include name="**/*.class" /> <exclude name="**/client/protocol/pb/*.class"/> <exclude name="**

Log4j Logger.getLogger(Class) throws NPE when running with jMockit and Cobertura

a 夏天 提交于 2019-12-23 20:04:34
问题 I have found a strange interaction between cobertura-maven-plugin 2.6 and jmockit 1.8. A particular pattern in our production code has a class with a lot of static methods that effectively wraps a different class that acts like a singleton. Writing unit tests for these classes went fine until I tried to run coverage reports with cobertura, when this error cropped up: java.lang.ExceptionInInitializerError at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at sun.reflect

Maven sonar plugin configurations for findbugs pmd checkstyle cobertura

╄→гoц情女王★ 提交于 2019-12-23 18:24:20
问题 I need some help in setting up code quality plugin for maven project. I have a multi module project. While I have configured pmd , checkstyle , findbugs and cobertura in my build process, and I can generate xml reports for each plugin, I am facing some challenges configuring the sonar plugin in my project. I am not sure how to approach this problem: Should I reuse the reports generated by these plugins while executing sonar? if so what should my sonar plugin configuration be? If I run sonar