Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EclEmma code coverage plugin and PowerMockRunner

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? :)

like image 766
dim0_0n Avatar asked Nov 20 '14 15:11

dim0_0n


1 Answers

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

like image 142
dkatzel Avatar answered Sep 22 '22 15:09

dkatzel