one static method calling another within a same class

31 views
Skip to first unread message

Kiran T

unread,
Jan 27, 2012, 11:21:13 AM1/27/12
to PowerMock
I am trying to test a scenario where one static method calls another
one within the same class but unable to do using PowerMock
( PowerMockEasyMock1.4.6).
I have test class annotated with
@RunWith(PowerMockRunner.class)
@PrepareForTest(MyUtil.class)
In my @Test JUnit method, I am doing a simple setup like this:
EasyMock.expect(MyUtil.testInner("someValue")).andReturn(true);
PowerMock.replayAll();
boolean status = MyUtil.testOuter();
PowerMock.verifyAll();

If I move testOuter() to some other class and do
OtherUtil.testOuter(), it works fine.
Is it true that PowerMock does not work in my scenario where one
static method calls another one inside the same class?

Thanks
Kiran

Johan Haleby

unread,
Feb 7, 2012, 6:12:26 AM2/7/12
to powe...@googlegroups.com
You have to use partial mocking. See the mockStaticPartial method in the PowerMock class. 

Regards,
/Johan

Kiran

--
You received this message because you are subscribed to the Google Groups "PowerMock" group.
To post to this group, send email to powe...@googlegroups.com.
To unsubscribe from this group, send email to powermock+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/powermock?hl=en.


Reply all
Reply to author
Forward
0 new messages