cobertura

Is there still no solution for ignoring setter/getter (other trivial methods) with the cobertura-maven-plugin?

帅比萌擦擦* 提交于 2019-12-06 17:14:08
问题 Did someone find a good solution to ignore trivial methods ? Using some automated testing like Unitils is not really an option, since the code-coverage should not go up if only getters/setters are tested! Using cobertrua-maven-plugin version 2.5.1 : -) ignore for methods does not work <ignore>com.company.*.set*</ignore> -) did anyone try to include a patch like http://sourceforge.net/tracker/index.php?func=detail&aid=3010530&group_id=130558&atid=720017 into the maven-plugin? -) anyone uses a

Excluding plugins from Cobertura reports in Grails

点点圈 提交于 2019-12-06 16:38:10
I'm using SpringSecurity plugin in my project and also Cobertura plugin for code coverage reports. The thing is I'd like the SpringSecurity specific classes (login and logout controllers, persistent login token and so on) to be excluded from my reports, since I assume they work properly. I'd like reports to contain only my project specific classes code coverage. Is there any way I can achieve that? coverage { exclusions = ['**/grails-app/conf/**','**/*any.other.package*','**/*any.class*'] xml = true enabledByDefault = true } Add the above snippet and configure the exclusions list in

How to remove specific Cobertura warning?

Deadly 提交于 2019-12-06 13:39:18
When i am running my ANT build script, Cobertura is complaining with the following warning. With that, i am wondering what it means really and how can i turn it off. [ cobertura-instrument] WARN visitEnd, No line number information found for class com.x.y.z.A. Perhaps you need to compile with debug=true? ANT sample below: <target name="instrument" depends="init,compile" > <delete file="cobertura.ser" /> <delete dir="${instrumented}" /> <cobertura-instrument todir="${instrumented}"> <ignore regex="org.apache.log4j.*" /> <fileset dir="${build}" > <include name="**/*.class" /> <exclude name="**

如何测试私有函数或具有私有方法,字段或内部类的类?

为君一笑 提交于 2019-12-06 08:31:52
如何对具有内部私有方法,字段或嵌套类的类进行单元测试(使用xUnit)? 还是通过 内部链接 (在C / C ++中为 static )或在私有( 匿名 )名称空间中使其私有化的函数? 仅仅为了能够运行测试而更改方法或函数的访问修饰符似乎很糟糕。 #1楼 过去,我曾使用 反射 来为Java执行此操作,我认为这是一个很大的错误。 严格来说,你 不 应该编写单元测试直接测试私有方法。 您 应该 测试的是该类与其他对象之间的公共合同; 您永远不要直接测试对象的内部。 如果另一个开发人员想要对该类进行小的内部更改,而不影响该类的公共合同,则他/她必须修改您基于反射的测试以确保它可以工作。 如果您在整个项目中重复执行此操作,则单元测试将不再是对代码运行状况的有用衡量,并开始成为开发的障碍和开发团队的烦恼。 我建议做的是使用诸如Cobertura之类的代码覆盖工具,以确保您编写的单元测试以私有方法提供对代码的适当覆盖。 这样,您可以间接测试私有方法的功能,并保持更高的敏捷性。 #2楼 今天,我推出了一个Java库来帮助测试私有方法和字段。 它的设计考虑了Android,但实际上可以用于任何Java项目。 如果您使用私有方法或字段或构造函数获取一些代码,则可以使用 BoundBox 。 它确实满足您的需求。 以下是一个测试示例,该示例访问一个Android活动的两个私有字段进行测试:

Cobertura and Jetty

醉酒当歌 提交于 2019-12-06 06:17:38
问题 I'm trying to get coverage report when running my webapp on Jetty, using cobertura. We already have cobertura running for unit-tests by using the surefire plugin. We also have the failsafe plugin configured for running our integration-tests. I've already (manually) instrumented my war and deployed it. When running mvn verify with integration-tests only profile, it seems cobertura is working because I get all kind of new warnings in eclipse console (i'm running jetty from there) probably

Cobertura coverage and the assert keyword

别说谁变了你拦得住时间么 提交于 2019-12-06 01:57:36
问题 My line coverage for unit tests measured by Cobertura is suffering, because I have assert statements which are not covered in tests. Should I be testing assert ions, and is there any way to get Cobertura to ignore them so they do not affect my test coverage? 回答1: The line coverage of your Java assert statements should be simply covered by running your test suite with assertions enabled, i.e., giving -ea as argument to the jvm. If you do this, you'll see that cobertura easily reports 100% line

Maven2 Multiproject Cobertura Reporting Problems During mvn site Build

自古美人都是妖i 提交于 2019-12-06 00:26:07
We've got a multiproject we're trying to run Cobertura test coverage reports on as part of our mvn site build. I can get Cobertura to run on the child projects, but it erroneously reports 0% coverage, even though the reports still highlight the lines of code that were hit by the unit tests. We are using mvn 2.0.8. I have tried running mvn clean site , mvn clean site:stage and mvn clean package site . I know the tests are running, they show up in the surefire reports (both the txt/xml and site reports). Am I missing something in the configuration? Does Cobertura not work right with

Cobertura ant script is missing Log4J classes

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 21:49:14
问题 I tried to get Cobertura running inside my ant script, but I'm stuck right at the beginning. When I try to insert the cobertura taskdef I'm missing the Log4J libraries. Ant properties & classpath <property name="cobertura.dir" location="/full/path/to/cobertura-1.9.3" /> <path id="cobertura.classpath"> <fileset dir="${cobertura.dir}"> <include name="cobertura.jar" /> <include name="lib/**/*.jar" /> </fileset> </path> <taskdef classpathref="cobertura.classpath" resource="tasks.properties" /> My

Why does Cobertura report 0% coverage when run through the Eclipse plugin?

…衆ロ難τιáo~ 提交于 2019-12-05 18:26:14
(There are a tonne of these questions, but all the ones I can find relate to Maven. Before you suggest this one is a duplicate, please understand that this doesn't relate to Maven in any way.) I am using Cobertura within Eclipse to determine my percentage of code covered by my JUnit tests. All 99 of my unit tests run successfully, both within and outside of Cobertura, but Cobertura reports back that they have covered 0% of my code. I : am running Cobertura through the Eclipse plugin am using Java 6, specifically OpenJDK-AMD64 on Ubuntu have ensured that the unit tests do cover some sections of

Cannot install Cobertura plugin for Eclipse

笑着哭i 提交于 2019-12-05 11:58:10
问题 I am getting following error message when I tried to install cobertura plugin in eclipse kepler (java/j2ee version) through eclipse market place. Cannot complete the install because one or more required items could not be found. Software being installed: eCobertura 0.9.8.201007202152 (ecobertura.feature.group 0.9.8.201007202152) Missing requirement: eCobertura 0.9.8.201007202152 (ecobertura.feature.group 0.9.8.201007202152) requires 'org.junit4 0.0.0' but it could not be found 回答1: I was able