Package com.episode6.reflectivemockk

Types

Link copied to clipboard
class ReflectiveStubbing<T : Any>(val self: T, kType: KType)

The receiver used to conveniently define reflective stubs on a mockK.

Link copied to clipboard
class TypeTokenResolutionError(referencedType: KType, context: KType) : AssertionError

Thrown when an error occurs while trying to resolve a KType into a concrete TypeToken

Functions

Link copied to clipboard
inline fun <RECEIVER : Any> <Error class: unknown class>.callTo(callable: KCallable<*>, receiver: RECEIVER): Any?
fun <Error class: unknown class>.callTo(    callable: KCallable<*>,     receiver: Any,     receiverType: KType): Any?

Allows for reflection-based stubbing of methods.

Link copied to clipboard
inline fun <T : Any> reflectiveMockk(    name: String? = null,     relaxed: Boolean = false,     vararg moreInterfaces: KClass<*>,     relaxUnitFun: Boolean = false,     stubbing: ReflectiveStubbing<T>.() -> Unit): T

Convenience method to create a new mockK with reflective stubs.

Link copied to clipboard
inline fun <T : Any> T.reflectiveStubs(stubbing: ReflectiveStubbing<T>.() -> Unit): T

Apply reflective stubs to an existing mockK.

Link copied to clipboard
inline suspend fun <RECEIVER : Any> <Error class: unknown class>.suspendCallTo(callable: KCallable<*>, receiver: RECEIVER): Any?
suspend fun <Error class: unknown class>.suspendCallTo(    callable: KCallable<*>,     receiver: Any,     receiverType: KType): Any?

Allows for reflection-based stubbing of suspend methods.