Package com.episode6.mockspresso2.plugins.mockito

Functions

Link copied to clipboard

Use mockito to generate fallback objects for dependencies that are not present in the mockspresso instance

Link copied to clipboard
inline fun <T> MockspressoBuilder.mock(    qualifier: Annotation? = null,     extraInterfaces: Array<out KClass<out Any>>? = null,     name: String? = null,     spiedInstance: Any? = null,     defaultAnswer: Answer<Any>? = null,     serializable: Boolean = false,     serializableMode: SerializableMode? = null,     verboseLogging: Boolean = false,     invocationListeners: Array<InvocationListener>? = null,     stubOnly: Boolean = false,     @Incubating useConstructor: UseConstructor? = null,     @Incubating outerInstance: Any? = null,     @Incubating lenient: Boolean = false): MockspressoBuilder
inline fun <T> MockspressoBuilder.mock(    qualifier: Annotation? = null,     extraInterfaces: Array<out KClass<out Any>>? = null,     name: String? = null,     spiedInstance: Any? = null,     defaultAnswer: Answer<Any>? = null,     serializable: Boolean = false,     serializableMode: SerializableMode? = null,     verboseLogging: Boolean = false,     invocationListeners: Array<InvocationListener>? = null,     stubOnly: Boolean = false,     @Incubating useConstructor: UseConstructor? = null,     @Incubating outerInstance: Any? = null,     @Incubating lenient: Boolean = false,     noinline stubbing: KStubbing<T>.(T) -> Unit): MockspressoBuilder

Add a mock with the supplied params as a dependency in this mockspresso instance. Mock will be bound with the supplied qualifier annotation. If you need a reference to the mock dependency, consider MockspressoProperties.mock instead.

inline fun <T> MockspressoProperties.mock(    qualifier: Annotation? = null,     extraInterfaces: Array<out KClass<out Any>>? = null,     name: String? = null,     spiedInstance: Any? = null,     defaultAnswer: Answer<Any>? = null,     serializable: Boolean = false,     serializableMode: SerializableMode? = null,     verboseLogging: Boolean = false,     invocationListeners: Array<InvocationListener>? = null,     stubOnly: Boolean = false,     @Incubating useConstructor: UseConstructor? = null,     @Incubating outerInstance: Any? = null,     @Incubating lenient: Boolean = false): Lazy<T>
inline fun <T> MockspressoProperties.mock(    qualifier: Annotation? = null,     extraInterfaces: Array<out KClass<out Any>>? = null,     name: String? = null,     spiedInstance: Any? = null,     defaultAnswer: Answer<Any>? = null,     serializable: Boolean = false,     serializableMode: SerializableMode? = null,     verboseLogging: Boolean = false,     invocationListeners: Array<InvocationListener>? = null,     stubOnly: Boolean = false,     @Incubating useConstructor: UseConstructor? = null,     @Incubating outerInstance: Any? = null,     @Incubating lenient: Boolean = false,     noinline stubbing: KStubbing<T>.(T) -> Unit): Lazy<T>

Add a mock with the supplied params as a dependency in this mockspresso instance. Mock will be bound with the supplied qualifier annotation and will be accessible via the returned lazy.

Link copied to clipboard
inline fun <T> MockspressoProperties.spy(qualifier: Annotation? = null): Lazy<T>

Create a real object of T using mockspresso then wrap it in a mockito spy. This spy will be part of the mockspresso graph and can be used by other real objects (and then verified in test code).

inline fun <T> MockspressoProperties.spy(qualifier: Annotation? = null, noinline stubbing: KStubbing<T>.(T) -> Unit): Lazy<T>

Create a real object of T using mockspresso then wrap it in a mockito spy. This spy will be part of the mockspresso graph and can be used by other real objects (and then verified in test code). The stubbing will be applied to the spy before it is injected as a dependency into other classes.

Link copied to clipboard
inline fun <BIND, IMPL : BIND> MockspressoProperties.spyImplOf(qualifier: Annotation? = null): Lazy<IMPL>

Create a real object of type IMPL using mockspresso then wrap it in a mockito spy (the object will be bound using type BIND). This spy will be part of the mockspresso graph and can be used by other real objects (and then verified in test code).

inline fun <BIND, IMPL : BIND> MockspressoProperties.spyImplOf(qualifier: Annotation? = null, noinline stubbing: KStubbing<IMPL>.(IMPL) -> Unit): Lazy<IMPL>

Create a real object of type IMPL using mockspresso then wrap it in a mockito spy (the object will be bound using type BIND). This spy will be part of the mockspresso graph and can be used by other real objects (and then verified in test code). The stubbing will be applied to the spy before it is injected as a dependency into other classes.