My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  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 linmingr...@gmail.com, 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.
N/A.
Oct 12, 2012
Project Member #1 johan.ha...@gmail.com
Could someone try if you get the same result if you test with the very latest (unreleased) Javassist?
Oct 16, 2012
#2 mahnk...@gmail.com
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
#3 ccha...@gmail.com
I have the same issue:

EclEmma 2.1.4.201208011137
Eclipse 4.2
OpenJDK 7
ArchLinux 3.6.2-1 i686
powermock-api-mockito 1.4.12
Oct 16, 2012
Project Member #4 johan.ha...@gmail.com
Did this occur with a new version of EclEmma or how come it has not been reported before?
Oct 17, 2012
#5 mahnk...@gmail.com
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 johan.ha...@gmail.com
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
#8 gabor.li...@gmail.com
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
#9 mahnk...@gmail.com
Please find attached a sample dummy project demonstrating the reported issue.

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

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


issue402-example.zip
3.9 KB   Download
Oct 17, 2012
#10 gabor.li...@gmail.com
Thanks for the sample classes.
Oct 17, 2012
#11 zalava...@gmail.com
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 johan.ha...@gmail.com
Then I suspect that problem must be fixed in Jacoco or Emma?
Oct 17, 2012
Project Member #14 johan.ha...@gmail.com
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
#15 zalava...@gmail.com
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
#16 zalava...@gmail.com
:)
Oct 18, 2012
#17 gabor.li...@gmail.com
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: http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=1179
Nov 19, 2012
#18 zalava...@gmail.com
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
#20 giovanim...@gmail.com
There forecasting correction?
Apr 14, 2013
#21 eric...@gmail.com
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
#22 hghazo...@gmail.com
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