public interface PowerMockitoStubber
extends org.mockito.stubbing.Stubber
Modifier and Type | Method and Description |
---|---|
void |
when(Class<?> classMock)
Allows to choose a static method when stubbing in
doThrow()|doAnswer()|doNothing()|doReturn() style
|
<T> PrivatelyExpectedArguments |
when(Class<T> classMock,
Method method)
Allows to mock a static private method when stubbing in
doThrow()|doAnswer()|doNothing()|doReturn() style.
|
<T> void |
when(Class<T> classMock,
Object... arguments)
Allows to mock a static private method based on the parameters when
stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.
|
<T> void |
when(Class<T> classMock,
String methodToExpect,
Object... arguments)
Allows to mock a static private method based on method name and
parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn()
style.
|
<T> PrivatelyExpectedArguments |
when(T mock,
Method method)
Allows to mock a private instance method when stubbing in
doThrow()|doAnswer()|doNothing()|doReturn() style.
|
<T> void |
when(T mock,
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,
String methodToExpect,
Object... arguments)
Allows to mock a private instance method based on method name and
parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn()
style.
|
void when(Class<?> classMock)
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)
classMock
- the mock classMockito
<T> PrivatelyExpectedArguments when(T mock, Method method) throws Exception
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)
mock
- the methodmethod
- private method to be mockedException
Mockito
<T> void when(T mock, Object... arguments) throws Exception
Example:
doThrow(new RuntimeException()).when(instance, parameter1, parameter2);
Read more about those methods:
Mockito.doThrow(Throwable...)
Mockito.doAnswer(Answer)
Mockito.doNothing()
Mockito.doReturn(Object)
mock
- the Mockarguments
- array of arguments is used to find suitable method to be mocked.Exception
Mockito
<T> void when(T mock, String methodToExpect, Object... arguments) throws Exception
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)
mock
- the MockmethodToExpect
- name of method which have to mockedarguments
- array of arguments of methodToExpect
Exception
Mockito
<T> PrivatelyExpectedArguments when(Class<T> classMock, Method method) throws Exception
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)
classMock
- class owner of private static methodmethod
- private static method to be mockedException
Mockito
<T> void when(Class<T> classMock, Object... arguments) throws Exception
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)
classMock
- class owner of private static methodarguments
- array of arguments is used to find suitable method to be mocked.Exception
Mockito
<T> void when(Class<T> classMock, String methodToExpect, Object... arguments) throws Exception
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)
classMock
- the class owner of static private methodmethodToExpect
- name of method which have to mockedarguments
- array of arguments of methodToExpect
Exception
Mockito
Copyright © 2019. All rights reserved.