cobertura

How to output coverage XML with nosetests?

两盒软妹~` 提交于 2019-12-05 01:03:55
I'm trying to output the coverage XML of my nosetests so they show up on Hudson. The line I'm executing is: nosetests --with-gae -v --all-modules --with-xunit --with-coverage I see the coverage output in the console, but there's no xml file containing the coverage data. How can I get it to output the coverage xml? Once you've run the nosetests command, there will be a .coverage data file in the directory. If you then run coverage xml , it will create a Cobertura-compatible XML file from the .coverage file. Jeremy Cunningham There is a plugin written for nosetests to do just this. You just have

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

最后都变了- 提交于 2019-12-04 22:51:28
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 different (better?) test-plugin? A general ignore for every get/set/is* method is also not really a

Ignore methods in class. cobertura maven plugin

百般思念 提交于 2019-12-04 15:56:41
I have maven 3, cobertura maven plugin 2.51 and some classe. I need to know test coverage of my class. But I don't want to test setters/getters. So I wand just to ignore them. <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.5.1</version> <configuration> <formats> <format>html</format> <format>xml</format> </formats> <check> <haltOnFailure>false</haltOnFailure> <lineRate>55</lineRate> <branchRate>60</branchRate> <packageLineRate>60</packageLineRate> <packageBranchRate>60</packageBranchRate> <totalLineRate>60</totalLineRate>

Unit tests passing through Maven, but failing through Cobertura: “Expecting a stackmap frame at branch target 65”

99封情书 提交于 2019-12-04 15:52:19
问题 I recently added the Cobertura plugin to my Java/Spring-MVC project. The strange thing is that all my unit tests were passing, and they still pass when Maven does its initial test run, but then when Cobertura tries to run the tests, they all fail with the same error message: Expecting a stackmap frame at branch target 65 in method xxx.xxxx.xxxx.xxxx;)V at offset 40 I have no idea why this is happening and don't even know how to go about fixing it. I've searched the internet but haven't found

Cobertura coverage and the assert keyword

时光总嘲笑我的痴心妄想 提交于 2019-12-04 06:15:21
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? 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 coverage if the rest of your lines are covered as well. Nevertheless, the assert lines will still be

Cobertura : how to cover spring-data @Repository interfaces

爷,独闯天下 提交于 2019-12-04 03:51:13
Regarding following information : https://stackoverflow.com/a/14601831/704246 Cobertura does not instrument interfaces I'd like to know how to add spring-data interfaces to coverage results, since @Repository implementation classes are only declared and instantiated by Spring at runtime. Consider following interface : // src/main/java/my/package/MyObjectRepository.java @Repository public interface MyObjectRepository { MyObject findMyObjectByCodeAndName(String code, String name); } and following test : // src/test/java/my/package/MyObjectRepositoryTest.java // @RunWith(SpringJUnit4ClassRunner

How does Cobertura work with JUnit?

ⅰ亾dé卋堺 提交于 2019-12-04 02:27:25
I can't understand how Cobertura cooperates with JUnit. As I understood cobertura modifies compiled byte code and inserts in this byte code its own commands. Ok. After that we run Junit framework and give it our tests to run. Could anyone explain at what points cobertura gets the information which of its commands were executed? Cobertura uses ASM which is a general purpose bytecode manipulation and analysis framework. On every line of java code there are 3 lines added to the existing classes to count things for the report it produces. When Cobertura is included in your classpath and configured

cobertura-maven-plugin excludes configuration

蹲街弑〆低调 提交于 2019-12-04 02:26:04
I have a Maven project with a test case DefaultViewTypeToFragmentMapperTest.java in the directory /src/test/java/test/com/mycompany/myproduct/android/viewtype2fragmentmapper/ . I want this test case to be excluded from unit test coverage calculation. In order to achieve this result, I configured the plugin like this: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.5.2</version> <configuration> <formats> <format>html</format> <format>xml</format> </formats> <instrumentation> <excludes> <exclude>test/co/**/*.class</exclude> </excludes> <

Ignoring report generation for specific classes in cobertura maven plugin

混江龙づ霸主 提交于 2019-12-04 02:25:25
I've been using Cobertura plugin for report generation and instrumentation (with surefire). Here is the issue I am facing: I am unable to make the plugin ignore report generation for specific classes in my project. PF below the related excerpt from pom.xml, I have added the ignore tag, but that just ignores instrumentation for the ignored classes. I want the report for specific projects to not be generated at all. Firstly, due to my limited knowledge of both Maven and Conberture, I want to know is it possible, and if yes, then what are the changes I need to get done in pom.xml. pom.xml <report

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

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