CallTracker

external class CallTracker(source)

This feature is deprecated and will be removed in a future version. Please consider using alternatives such as the mock helper function.

Since

v14.2.0, v12.19.0

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
external fun calls(exact: Number = definedExternally): () -> Unit

The wrapper function is expected to be called exactly exact times. If the function has not been called exactly exact times when tracker.verify() is called, then tracker.verify() will throw an error.

external fun <Func : Function<Any?>> calls(fn: Func, exact: Number = definedExternally): Func
external fun calls(fn: Nothing?, exact: Number = definedExternally): () -> Unit
Link copied to clipboard

Example:

Link copied to clipboard

The arrays contains information about the expected and actual number of calls of the functions that have not been called the expected number of times.

Link copied to clipboard
external fun reset(fn: Function<*> = definedExternally)

Reset calls of the call tracker. If a tracked function is passed as an argument, the calls will be reset for it. If no arguments are passed, all tracked functions will be reset.

Link copied to clipboard
external fun verify()

Iterates through the list of functions passed to {@link tracker.calls()} and will throw an error for functions that have not been called the expected number of times.