tag:blogger.com,1999:blog-3237724005744642470.post1788965298157625647..comments2020-11-17T09:20:38.485+00:00Comments on Captain Debug's Blog: Using PowerMock to Mock Static MethodsRoger Hugheshttp://www.blogger.com/profile/07042290171112551665[email protected]Blogger3125tag:blogger.com,1999:blog-3237724005744642470.post-35953742979813837492015-02-26T17:15:02.115+00:002015-02-26T17:15:02.115+00:00I realize it's 3 years later but I use eCobert...I realize it's 3 years later but I use eCobertura and EclEmma for eclipse.<br />eCobertura for most tests and EclEmma when I want coverage on something that eCobertura can't handle.<br />Note: I have to use the JVM arg -XX:-UseSplitVerifier for my unit tests or I get errors, also I have to add to the plug-ins dir an older version of junit to get one of the above coverage tools to install in eclipse.Hardy Chttps://www.blogger.com/profile/07582088658763874752[email protected]tag:blogger.com,1999:blog-3237724005744642470.post-38370000197837330372012-04-06T16:40:46.976+01:002012-04-06T16:40:46.976+01:00Diana,
I'm not sure what the answer to your pr...Diana,<br />I'm not sure what the answer to your problem is, but I'd hazard a guess that changing from the default JUnit test runner to the PowerMockRunner using:<br /><br />@RunWith(PowerMockRunner.class)<br /><br />will be the cause of the problems. As they say on the Powermock website "PowerMock uses a custom classloader and byte code manipulation" - which means that when you then add: <br /><br />@PrepareForTest(UsesResourceBundle.class)<br /><br />it'll tell PowerMock to starting doing some jiggery-pokery with your code that will confuse whatever code coverage method you're using.Roger Hugheshttps://www.blogger.com/profile/07042290171112551665[email protected]tag:blogger.com,1999:blog-3237724005744642470.post-12791018330653162322012-04-02T15:35:20.798+01:002012-04-02T15:35:20.798+01:00Hi Roger,
What about code coverage? When I add my...Hi Roger,<br /><br />What about code coverage? When I add my class to @PrepareForTest, the coverage is ignored....<br /><br />I'm running JUnits for code coverage purpose, can you help me with this?<br /><br />Thanks in advance!Diana[email protected]