spyk

inline fun <T : Any> spyk(    name: String? = null,     vararg moreInterfaces: KClass<*>,     recordPrivateCalls: Boolean = false,     block: T.() -> Unit = {}): T

Builds a new spy for specified class. Initializes object via default constructor.

A spy is a special kind of mockk that enables a mix of mocked behaviour and real behaviour. A part of the behaviour may be mocked using every, but any non-mocked behaviour will call the original method.

Parameters

name

spyk name

moreInterfaces

additional interfaces for this spyk to implement, in addition to the specified class.

recordPrivateCalls

allows this spyk to record any private calls, enabling a verification.

block

block to execute after spyk is created with spyk as a receiver. Similar to using apply on the spyk object.


inline fun <T : Any> spyk(    objToCopy: T,     name: String? = null,     vararg moreInterfaces: KClass<*>,     recordPrivateCalls: Boolean = false,     block: T.() -> Unit = {}): T

Builds a new spy for specified class, copying fields from objToCopy.

A spy is a special kind of mockk that enables a mix of mocked behaviour and real behaviour. A part of the behaviour may be mocked using every, but any non-mocked behaviour will call the original method.

Parameters

name

spyk name

moreInterfaces

additional interfaces for this spyk to implement, in addition to the specified class.

recordPrivateCalls

allows this spyk to record any private calls, enabling a verification.

block

block to execute after spyk is created with spyk as a receiver. Similar to using apply on the spyk object.