Interface PowerMockitoStubber
- All Superinterfaces:
org.mockito.stubbing.BaseStubber
,org.mockito.stubbing.Stubber
- All Known Implementing Classes:
PowerMockitoStubberImpl
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Allows to choose a static method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style<T> void
Allows to mock a static private method based on the parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Allows to mock a static private method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.<T> void
Allows to mock a static private method based on method name and parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.<T> void
Allows to mock a private instance method based on the parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Allows to mock a private instance method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.<T> void
Allows to mock a private instance method based on method name and parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Methods inherited from interface org.mockito.stubbing.BaseStubber
doAnswer, doCallRealMethod, doNothing, doReturn, doReturn, doThrow, doThrow, doThrow
Methods inherited from interface org.mockito.stubbing.Stubber
when
-
Method Details
-
when
Allows to choose a static method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() styleExample:
doThrow(new RuntimeException()).when(StaticList.class); StaticList.clear(); //following throws RuntimeException: StaticList.clear();
Read more about those methods:
Mockito.doThrow(Class)
Mockito.doAnswer(Answer)
Mockito.doNothing()
Mockito.doReturn(Object)
- Parameters:
classMock
- the mock class- See Also:
-
when
Allows to mock a private instance method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Example:
doThrow(new RuntimeException()).when(instance, method("myMethod")).withNoArguments();
Read more about those methods:
Mockito.doThrow(Class)
Mockito.doAnswer(Answer)
Mockito.doNothing()
Mockito.doReturn(Object)
- Parameters:
mock
- the methodmethod
- private method to be mocked- Throws:
Exception
- See Also:
-
when
Allows to mock a private instance method based on the parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Example:
doThrow(new RuntimeException()).when(instance, parameter1, parameter2);
Read more about those methods:
Mockito.doThrow(Throwable...)
Mockito.doAnswer(Answer)
Mockito.doNothing()
Mockito.doReturn(Object)
- Parameters:
mock
- the Mockarguments
- array of arguments is used to find suitable method to be mocked.- Throws:
Exception
- See Also:
-
when
Allows to mock a private instance method based on method name and parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Example:
doThrow(new RuntimeException()).when(instance, "methodName", parameter1, parameter2);
Read more about those methods:
Mockito.doThrow(Throwable...)
Mockito.doAnswer(Answer)
Mockito.doNothing()
Mockito.doReturn(Object)
- Parameters:
mock
- the MockmethodToExpect
- name of method which have to mockedarguments
- array of arguments ofmethodToExpect
- Throws:
Exception
- See Also:
-
when
Allows to mock a static private method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Example:
doThrow(new RuntimeException()).when(MyClass.class, method("myMethod")).withNoArguments();
Read more about those methods:
Mockito.doThrow(Throwable...)
Mockito.doAnswer(Answer)
Mockito.doNothing()
Mockito.doReturn(Object)
- Parameters:
classMock
- class owner of private static methodmethod
- private static method to be mocked- Throws:
Exception
- See Also:
-
when
Allows to mock a static private method based on the parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Example:
doThrow(new RuntimeException()).when(MyClass.class, parameter1, parameter2);
Read more about those methods:
Mockito.doThrow(Throwable...)
Mockito.doAnswer(Answer)
Mockito.doNothing()
Mockito.doReturn(Object)
- Parameters:
classMock
- class owner of private static methodarguments
- array of arguments is used to find suitable method to be mocked.- Throws:
Exception
- See Also:
-
when
Allows to mock a static private method based on method name and parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Example:
doThrow(new RuntimeException()).when(MyClass.class, "methodName", parameter1, parameter2);
Read more about those methods:
Mockito.doThrow(Throwable...)
Mockito.doAnswer(Answer)
Mockito.doNothing()
Mockito.doReturn(Object)
- Parameters:
classMock
- the class owner of static private methodmethodToExpect
- name of method which have to mockedarguments
- array of arguments ofmethodToExpect
- Throws:
Exception
- See Also:
-