BlockingSequentialAnswerBuilder

Marker interface for sequential answer builder for non-suspend function

Functions

Link copied to clipboard
abstract infix fun answers(answer: Answer<T>)

Registers given answer for a function call. Direct usage requires care, because it allows to register suspending answer for non-suspend function.

Link copied to clipboard
infix fun <T> AnsweringScope<T>.calls(superCall: SuperCall)

Calls super method according to SuperCall.

Function call executes block.

Link copied to clipboard

Function call executes block inside runCatching and returns Result. It rethrows any dev.mokkery.MokkeryRuntimeException as it indicates internal error and cannot be ignored.

Link copied to clipboard

Allows to define a set of answers in sequentially that will repeat in cycles.

Link copied to clipboard
infix fun <T> AnsweringScope<T>.returns(value: T)

Function call always returns value.

Link copied to clipboard
infix fun <T> AnsweringScope<T>.returnsArgAt(index: Int)

Function call returns argument at index.

Link copied to clipboard
infix fun <T> AnsweringScope<T>.returnsBy(function: () -> T)

Function call returns value provided each time by function.

Link copied to clipboard
infix fun <T> AnsweringScope<in Result<T>>.returnsFailure(error: Throwable)

Function call returns Result.failure with error.

Link copied to clipboard
infix fun <T> AnsweringScope<in Result<T>>.returnsFailureBy(function: () -> Throwable)

Function call returns Result.failure with exception provided each time by function.

Link copied to clipboard
infix fun <T> AnsweringScope<in Result<T>>.returnsSuccess(value: T)

Function call returns Result.success with value.

Link copied to clipboard
infix fun <T> AnsweringScope<in Result<T>>.returnsSuccessBy(function: () -> T)

Function call returns Result.success with value provided each time by function.

Link copied to clipboard

Function call will answer sequentially with answers defined in block.

Link copied to clipboard

Simplification for sequentially with multiple returns calls.

Link copied to clipboard

Simplification for sequentially with multiple throws calls.

Link copied to clipboard
infix fun <T> AnsweringScope<T>.throws(error: Throwable)

Function call always throws error.

Link copied to clipboard
infix fun <T> AnsweringScope<T>.throwsBy(function: () -> Throwable)

Function call throws exception provided each time by function.

Link copied to clipboard
infix fun <T> AnsweringScope<T>.throwsErrorWith(message: Any)

Function call always throws an IllegalStateException with given message.