EclEmma代码覆盖插件和PowerMockRunner

编程入门 行业动态 更新时间:2024-10-18 18:23:30
本文介绍了EclEmma代码覆盖插件和PowerMockRunner的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我遇到了在Eclipse中使用EclEmma插件的问题。 当我使用注释时,它不显示代码覆盖率 @RunWith 传递(PowerMockRunner.class) as一个论据。如果使用(MockitoJUnitRunner.class)一切都很好。 等待您的建议? :)

解决方案

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

更详细地讨论:

使用JUnit和Powermock的Emma代码覆盖

http:/ /code.google/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

code.google/p/powermock/issues/detail?id=402

更多推荐

EclEmma代码覆盖插件和PowerMockRunner

本文发布于:2023-10-31 04:35:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545023.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:插件   代码   EclEmma   PowerMockRunner

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!