My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
  Advanced search   Search tips   Subscriptions
Issue 402: PowerMock disables EclEmma code coverage
21 people starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----

Sign in to add a comment
Reported by, Sep 10, 2012
What steps will reproduce the problem?
1.Create a powermock test with Mockito, the test class is decorated with @RunWith and @PrepareForTest annotation.
2.Run the Test with "coverage as".

What is the expected output? What do you see instead?
Expected: EclEmma shows correct code coverage report.
Instead: EclEmma shows zero code coverage on target class.

What version of the product are you using? On what operating system?
 1. Eclipse is 3.7. 
 2. EclEmma Plugin: 2.1.4. 
 3. PowerMock: powermock-mockito-1.4.12-full.jar.
 4. OS: Windows XP sp2. 
 5. JDK: 1.6.

Please provide any additional information below.
Oct 12, 2012
Project Member #1
Could someone try if you get the same result if you test with the very latest (unreleased) Javassist?
Oct 16, 2012
We are using latest unreleased Javassist and can confirm that the coverage report shows zero code coverage when using powermock tests with Mockito as reported in the original post.
Oct 16, 2012
I have the same issue:

Eclipse 4.2
OpenJDK 7
ArchLinux 3.6.2-1 i686
powermock-api-mockito 1.4.12
Oct 16, 2012
Project Member #4
Did this occur with a new version of EclEmma or how come it has not been reported before?
Oct 17, 2012
In our case we started to use powermock in order to be able to mock static methods and since then code coverage reports are incorrectly showing zero code coverage for the class we are testing using powermock.
Oct 17, 2012
Project Member #6
Alright. I know cobertura had the same issue before but then it was an issue on their side this they fixed it a later version. Perhaps you can bring this up to Emma as well?
Oct 17, 2012
If someone would have time to provide a test and a dummy class attached to this class, that would be useful for both parties.
Oct 17, 2012
Please find attached a sample dummy project demonstrating the reported issue.

When running code coverage for unit test "", it shows zero % coverage in src/main/java

When running code coverage for unit test "", it shows correct coverage % in src/main/java
3.9 KB   Download
Oct 17, 2012
Thanks for the sample classes.
Oct 17, 2012
This problem began with EclEmma 2.0.0, where they started using Jacoco.
With EclEmma 1.5.3 there is no such problem.
Oct 17, 2012
Project Member #12
Then I suspect that problem must be fixed in Jacoco or Emma?
Oct 17, 2012
Project Member #14
Ok so there it says that "JaCoCo uses a hashcode of the class definition for class identity" so that's probably the reason why it won't work. PowerMock cannot work with modifying classes so I guess there's nothing that can be done in PowerMock to prevent this.. (correct me if I'm wrong).
Oct 17, 2012
The root of the problem: "JaCoCo uses a hashcode of the class definition for class identity."
So the cglib modified classes has different hashcodes than the originals.
I don't think the PowerMock guys can solve this problem, so I think this will be a long-term problem.
Oct 17, 2012
Oct 18, 2012
I have just installed ecobertura. Works perfectly together with eclemma inside one eclipse. It is less handy as eclemma, but it delivers correct coverage. If you drag this link on eclipse, you can install that easily:
Nov 19, 2012
Yes, Cobertura is okay but it is not maintained anymore. (It hasn't got any update since 2011 june, so this is not a long term solution I think)

At the company we using Sonar, it has Cobertura and Jacoco plugins as well, but the supported way in sonar is also Jacoco for sime time.

Feb 22, 2013
#19 headcrashing
Seems to be related to #432.
Apr 10, 2013
There forecasting correction?
Apr 14, 2013
We use EasyMock with PowerMock and got similar issue. The only difference is that we always got 100% coverage of the under test class, even though there are lines not covered.
Jun 26, 2013
I just tried using Clover with Powermock and it works. Not free but at least it works. 
Sign in to add a comment

Powered by Google Project Hosting