public class PowerMockitoStubberImpl extends org.mockito.internal.stubbing.StubberImpl implements PowerMockitoStubber
Constructor and Description |
---|
PowerMockitoStubberImpl() |
Modifier and Type | Method and Description |
---|---|
void |
when(java.lang.Class<?> classMock)
Allows to choose a static method when stubbing in
doThrow()|doAnswer()|doNothing()|doReturn() style
|
<T> PrivatelyExpectedArguments |
when(java.lang.Class<T> classMock,
java.lang.reflect.Method method)
Allows to mock a static private method when stubbing in
doThrow()|doAnswer()|doNothing()|doReturn() style.
|
<T> void |
when(java.lang.Class<T> classMock,
java.lang.Object... arguments)
Allows to mock a static private method based on the parameters when
stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.
|
<T> void |
when(java.lang.Class<T> classMock,
java.lang.String methodToExpect,
java.lang.Object... parameters)
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> PrivatelyExpectedArguments |
when(T mock,
java.lang.reflect.Method method)
Allows to mock a private instance method when stubbing in
doThrow()|doAnswer()|doNothing()|doReturn() style.
|
<T> void |
when(T mock,
java.lang.Object... arguments)
Allows to mock a private instance method based on the parameters when
stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.
|
<T> void |
when(T mock,
java.lang.String methodToExpect,
java.lang.Object... arguments)
Allows to mock a private instance method based on method name and
parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn()
style.
|
doAnswer, doCallRealMethod, doNothing, doReturn, doReturn, doThrow, doThrow, doThrow
public void when(java.lang.Class<?> classMock)
PowerMockitoStubber
Example:
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)
when
in interface PowerMockitoStubber
classMock
- the mock classMockito
public <T> T when(T instanceMock)
mock
is not a PowerMockito
mock it will delegate to Mockito.when
in interface org.mockito.stubbing.Stubber
when
in class org.mockito.internal.stubbing.StubberImpl
Stubber.when(Object)
public <T> PrivatelyExpectedArguments when(T mock, java.lang.reflect.Method method) throws java.lang.Exception
PowerMockitoStubber
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)
when
in interface PowerMockitoStubber
mock
- the methodmethod
- private method to be mockedjava.lang.Exception
Mockito
public <T> void when(T mock, java.lang.Object... arguments) throws java.lang.Exception
PowerMockitoStubber
Example:
doThrow(new RuntimeException()).when(instance, parameter1, parameter2);
Read more about those methods:
Mockito.doThrow(Throwable...)
Mockito.doAnswer(Answer)
Mockito.doNothing()
Mockito.doReturn(Object)
when
in interface PowerMockitoStubber
mock
- the Mockarguments
- array of arguments is used to find suitable method to be mocked.java.lang.Exception
Mockito
public <T> void when(T mock, java.lang.String methodToExpect, java.lang.Object... arguments) throws java.lang.Exception
PowerMockitoStubber
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)
when
in interface PowerMockitoStubber
mock
- the MockmethodToExpect
- name of method which have to mockedarguments
- array of arguments of methodToExpect
java.lang.Exception
Mockito
public <T> void when(java.lang.Class<T> classMock, java.lang.Object... arguments) throws java.lang.Exception
PowerMockitoStubber
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)
when
in interface PowerMockitoStubber
classMock
- class owner of private static methodarguments
- array of arguments is used to find suitable method to be mocked.java.lang.Exception
Mockito
public <T> void when(java.lang.Class<T> classMock, java.lang.String methodToExpect, java.lang.Object... parameters) throws java.lang.Exception
PowerMockitoStubber
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)
when
in interface PowerMockitoStubber
classMock
- the class owner of static private methodmethodToExpect
- name of method which have to mockedparameters
- array of arguments of methodToExpect
java.lang.Exception
Mockito
public <T> PrivatelyExpectedArguments when(java.lang.Class<T> classMock, java.lang.reflect.Method method) throws java.lang.Exception
PowerMockitoStubber
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)
when
in interface PowerMockitoStubber
classMock
- class owner of private static methodmethod
- private static method to be mockedjava.lang.Exception
Mockito