Cobertura 测试覆盖范围不涵盖扩展被测类的测试
我有一堂课需要测试,例如。 MyClass.java
我正在使用 Junit4,因此为了在 MyClass.java 中测试受保护的方法,我创建了一个测试类 MyClassTest.java (它位于完全不同的包中,因此无法测试受保护的方法)。
我已经为 MyClass 中的所有方法编写了测试,并且 MyClassTest 在运行时成功。
当我对项目中的所有类运行 Cobertura 测试覆盖率时,效果很好,并且根据编写的测试,我得到了 0-100% 的不同覆盖率。
然而,Cobertura 报告说 MyClass 的覆盖率是 0%,因为它没有经过测试——它实际上是经过测试的子类。
有没有什么方法可以让 Cobertura 认识到所有被测试的方法都在父类中,并将其作为覆盖范围?
谢谢
I have a class which I need to test eg. MyClass.java
I am using Junit4 so in order to test the protected methods as well in MyClass.java I create a test class MyClassTest.java (which is in a completely different package hence the inability to test the protected method otherwise).
I have written tests for all methods in MyClass and MyClassTest succeeds when run.
When I run the Cobertura test coverage for all classes in the project, this works fine and I get varying coverage from 0-100% according to tests written.
Cobertura reports however that MyClass has 0% coverage as it was not tested - it was infact the subclass that was tested.
Is there any way of making Cobertura pick up the fact that all methods being tested are within the parent class and picking that up as coverage??
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论