Answer

interface Answer<out T>

An answer for a function call. For blocking answers only call implementation is required. For suspending answers callSuspend should be implemented and call implementation should throw an exception. Use Suspending for convenience.

Inheritors

Types

Link copied to clipboard
object Autofill : Answer<Any?>

Used whenever there is no defined answer for a call to mock that is in dev.mokkery.MockMode.autofill. Refer to AutofillProvider.forMockMode to read more about returned values.

Link copied to clipboard
class Block<T>(val block: BlockingCallDefinitionScope<T>.(CallArgs) -> T) : Answer<T>

Calls block on call and callSuspend.

Link copied to clipboard

Just like Block but for suspending functions.

Link copied to clipboard
class Const<T>(val value: T) : Answer<T>

Returns value on call and callSuspend.

Link copied to clipboard
interface Sequential<T> : Answer<T>

Interface for every answer that have to be called in repeat when specified in sequentially.

Link copied to clipboard

Returns results of answers from iterator until empty. It supports nested Sequential answers and calls them until they are empty.

Link copied to clipboard
interface Suspending<T> : Answer<T>

Convenience interface for custom suspending answers. By default, it throws runtime exception on call.

Link copied to clipboard
class Throws(val throwable: Throwable) : Answer<Nothing>

Throws throwable on call and callSuspend

Functions

Link copied to clipboard
abstract fun call(scope: FunctionScope): T

Provides a return value for a function call with given scope.

Link copied to clipboard
open suspend fun callSuspend(scope: FunctionScope): T

Just like call but suspends. By default, it calls call.

Link copied to clipboard
open fun description(): String

Returns human-readable answer description. By default, it returns answers $this. It's used for debugging purposes.