EclEmma代码覆盖插件和PowerMockRunner [英] EclEmma code coverage plugin and PowerMockRunner

查看:906
本文介绍了EclEmma代码覆盖插件和PowerMockRunner的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了在Eclipse中使用EclEmma插件的问题。
当我使用注释时,它不显示代码覆盖率 @RunWith 传递(PowerMockRunner.class) as一个论据。如果使用(MockitoJUnitRunner.class)一切都很好。
等待您的建议? :)

解决方案

这是Eclemma(JaCoCo)的已知问题。基本上两个库都修改字节码,但Mockito会在运行时修改它,这会产生一个不同的二进制文件。 JaCoCo显然使用通过hashMap来跟踪它正在观看的类,其hashcode是由类定义导出的,所以在Mockito修改类之后,哈希码将不同,所以JaCoco不再在其内部地图中找到类。



更详细地讨论:





使用JUnit和Powermock的Emma代码覆盖



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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆