#122 Coverage Red when using PowerMock with PrepareForTest

Version 2.1.1
closed-wont-fix
nobody
5
2012-07-12
2012-04-20
Rafael Chies
No

The coverage result shows that code in test is not covered, when actually it is.
The problem happens when the test class is coded using powermock, and the class in test is declared into @PrepareForTest.

Imagine a scene, where I have a class called TaxiFacade and the test class TaxiFacadeTest. The coverage mistake happens when the test class has the code as the bellow example, with the implementation class (TaxiFacade) declared inside the @PrepareForTest

@RunWith(PowerMockRunner.class)
@PrepareForTest({
TaxiFacade.class
})
public class TaxiFacadeTest {

......

I think the description above is enough to reproduce the case. However, if a real uni test be necessary, let me know.

Thanks in advice.

Discussion

  • This is a known limitation of JaCoCo. If a class file gets modified at runtime (by powermock) it will not match any more at analysis time afterwards.

     
    • status: open --> closed-wont-fix