|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mockito.configuration.experimental.ConfigurationSupport
public class ConfigurationSupport
Allows configuring Mockito to enable custom 'mocking style'. It can be useful when working with legacy code, etc.
See examples from mockito/test/org/mockitousage/examples/configure subpackage. You may want to check out the project from svn repository to easily browse Mockito's test code.
Basic example:
//create an implementation of ReturnValues interface
public class FriendlyReturnValues implements ReturnValues {
public Object valueFor(InvocationOnMock invocation) {
Class> returnType = invocation.getMethod().getReturnType();
Object defaultReturnValue = ConfigurationSupport.defaultValueFor(invocation);
if (defaultReturnValue != null || !ConfigurationSupport.isMockable(returnType)) {
return defaultReturnValue;
} else {
return Mockito.mock(returnType);
}
}
//finally, change the configuration:
ConfigurationSupport.getConfiguration().setReturnValues(new FriendlyReturnValues());
Configuring Mockito is a new concept that we evaluate. Please let us know if you find it useful/harmful.
| Constructor Summary | |
|---|---|
ConfigurationSupport()
|
|
| Method Summary | |
|---|---|
static java.lang.Object |
defaultValueFor(InvocationOnMock invocation)
this is what Mockito returns by default for given invocation |
static MockitoConfiguration |
getConfiguration()
returns a configuration object |
static boolean |
isMockable(java.lang.Class<?> clazz)
returns true if Mockito CAN create mocks of the clazz |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConfigurationSupport()
| Method Detail |
|---|
public static java.lang.Object defaultValueFor(InvocationOnMock invocation)
See examples in javadoc for ConfigurationSupport
invocation -
public static boolean isMockable(java.lang.Class<?> clazz)
See examples in javadoc for ConfigurationSupport
clazz -
public static MockitoConfiguration getConfiguration()
See examples in javadoc for ConfigurationSupport
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||