AutoworkSpy๏ƒ

Experimental: Some methods may not be implemented and may be changed in future versions.

Inherits: RefCounted < Object

Records and inspects method calls during tests.

Description๏ƒ

The AutoworkSpy is used to track and analyze method calls made on objects during testing.

It records each invocation, including the target object, method name, and arguments passed.

This allows tests to verify that specific methods were called, how many times they were called, and with what parameters.

Methods๏ƒ

void

add_call(object: Variant, method_name: StringName, args: Array)

int

call_count(object: Variant, method_name: StringName, args: Variant = null)

void

clear()

Array

get_call_parameters(object: Variant, method_name: StringName, index: int = -1)

bool

was_called(object: Variant, method_name: StringName, args: Variant = null)


Method Descriptions๏ƒ

void add_call(object: Variant, method_name: StringName, args: Array) ๐Ÿ”—

Stores the call information for later inspection, including the object, method_name, and arguments passed in args.


int call_count(object: Variant, method_name: StringName, args: Variant = null) ๐Ÿ”—

Returns the number of times a method was called.

If args is provided, only calls matching the given arguments are counted.

Otherwise, all calls to the specified method are included.


void clear() ๐Ÿ”—

Clears all recorded method calls.

After calling this method, the spy returns to an empty state with no stored invocation history.


Array get_call_parameters(object: Variant, method_name: StringName, index: int = -1) ๐Ÿ”—

Returns the parameters used in recorded method calls.

If index is provided, returns the arguments for that specific call instance.

If index is -1, returns all recorded argument sets for the method.


bool was_called(object: Variant, method_name: StringName, args: Variant = null) ๐Ÿ”—

Returns true if the specified method was called.

If args is provided, the check is refined to match calls with those exact arguments.

Otherwise, any call to the method is considered a match.