1

Getting the exception:

although stubbed methods may return mocks, you cannot inline mock creation (mock()) call inside a thenReturn method (see issue 53)

I am following the https://code.google.com/p/powermock/wiki/MockitoUsage

PowerMockito.mockStatic(MyUtil.class);

Mockito.when(MyUtil.compareVersion("1","2")).thenReturn(200);

Also I want to mock this class partial, there are others methods in this class, which I don't want to mock, they should run as usual.

Detailed Exception :

org.mockito.exceptions.misusing.UnfinishedStubbingException: 
Unfinished stubbing detected here:
-> at org.powermock.api.mockito.internal.PowerMockitoCore.doAnswer(PowerMockitoCore.java:31)

1 Answer 1

0

I can't tell from your code snippet but do you have the following annotations on your test class?

@RunWith(PowerMockRunner.class)
@PrepareForTest(MyUtil.class)
public class MyUtilTest {

Additionally, you should look at https://code.google.com/p/powermock/wiki/MockitoUsage13 for newer versions of PowerMock.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.