Class PowerMockitoStubberImpl
- All Implemented Interfaces:
org.mockito.stubbing.Stubber
,PowerMockitoStubber
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addAnswersForStubbing
(MockitoMethodInvocationControl invocationControl) private void
assertNotNull
(Object object, String name) private <T> void
prepareForStubbing
(T mock) void
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> T
when
(T instanceMock) Supports PowerMockito mocks.<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 class org.mockito.internal.stubbing.StubberImpl
doAnswer, doCallRealMethod, doNothing, doReturn, doThrow, doThrow
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.mockito.stubbing.Stubber
doAnswer, doCallRealMethod, doNothing, doReturn, doThrow, doThrow
-
Constructor Details
-
PowerMockitoStubberImpl
public PowerMockitoStubberImpl()
-
-
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(Throwable)
Mockito.doAnswer(Answer)
Mockito.doNothing()
Mockito.doReturn(Object)
See examples in javadoc for
Mockito
- Specified by:
when
in interfacePowerMockitoStubber
-
when
public <T> T when(T instanceMock) Supports PowerMockito mocks. Ifmock
is not a PowerMockito mock it will delegate to Mockito.- Specified by:
when
in interfaceorg.mockito.stubbing.Stubber
- Overrides:
when
in classorg.mockito.internal.stubbing.StubberImpl
- See Also:
-
addAnswersForStubbing
-
when
Description copied from interface:PowerMockitoStubber
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(Throwable)
Mockito.doAnswer(Answer)
Mockito.doNothing()
Mockito.doReturn(Object)
See examples in javadoc for
Mockito
- Specified by:
when
in interfacePowerMockitoStubber
- Throws:
Exception
-
when
Description copied from interface:PowerMockitoStubber
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)
See examples in javadoc for
Mockito
- Specified by:
when
in interfacePowerMockitoStubber
- Throws:
Exception
-
when
Description copied from interface:PowerMockitoStubber
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)
See examples in javadoc for
Mockito
- Specified by:
when
in interfacePowerMockitoStubber
- Throws:
Exception
-
when
Description copied from interface:PowerMockitoStubber
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)
See examples in javadoc for
Mockito
- Specified by:
when
in interfacePowerMockitoStubber
- Throws:
Exception
-
when
public <T> void when(Class<T> classMock, String methodToExpect, Object... parameters) throws Exception Description copied from interface:PowerMockitoStubber
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)
See examples in javadoc for
Mockito
- Specified by:
when
in interfacePowerMockitoStubber
- Throws:
Exception
-
when
Description copied from interface:PowerMockitoStubber
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)
See examples in javadoc for
Mockito
- Specified by:
when
in interfacePowerMockitoStubber
- Throws:
Exception
-
assertNotNull
-
prepareForStubbing
private <T> void prepareForStubbing(T mock)
-