EclEmma代码覆盖插件和PowerMockRunner [英] EclEmma code coverage plugin and PowerMockRunner
问题描述
当我使用注释时,它不显示代码覆盖率
@RunWith
传递(PowerMockRunner.class)
as一个论据。如果使用(MockitoJUnitRunner.class)
一切都很好。 等待您的建议? :)
这是Eclemma(JaCoCo)的已知问题。基本上两个库都修改字节码,但Mockito会在运行时修改它,这会产生一个不同的二进制文件。 JaCoCo显然使用通过hashMap来跟踪它正在观看的类,其hashcode是由类定义导出的,所以在Mockito修改类之后,哈希码将不同,所以JaCoco不再在其内部地图中找到类。
更详细地讨论:
http:/ /code.google.com/p/powermock/issues/detail?id=402
I met a problem of using EclEmma plugin in Eclipse.
It doesn't show code coverage when I use annotation @RunWith
passing (PowerMockRunner.class)
as an argument. In case of using (MockitoJUnitRunner.class)
everything is fine.
Waiting for your suggestions? :)
This is a known problem with Eclemma (JaCoCo). Basically both libraries modify byte code but Mockito modifies it during runtime which produces a different binary .class file. JaCoCo apparently uses keeps track of the classes it's watching via a hashMap whose hashcode is derived by the class definition so the hashcode will be different after Mockito modifies the class so JaCoco can't find the class in it's internal Maps anymore.
Discussed in more detail:
Why EclEmma doesn't coverage code with tests with @RunWith(PowerMockRunner.class)
Emma code coverage with JUnit and Powermock
http://code.google.com/p/powermock/issues/detail?id=402
这篇关于EclEmma代码覆盖插件和PowerMockRunner的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!