AutoworkStubber๏ƒ

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

Inherits: RefCounted < Object

Defines and manages stubbed method behavior for test doubles.

Description๏ƒ

The AutoworkStubber is responsible for overriding method behavior during tests by defining custom return values.

It allows tests to replace real method implementations with controlled responses, enabling deterministic and isolated testing.

Stubs can be defined globally for a method or conditionally based on arguments.

Methods๏ƒ

void

clear()

Variant

get_return(object: Variant, method_name: StringName, args: Array = [])

void

set_return(object: Variant, method_name: StringName, return_value: Variant, args: Variant = null)

bool

should_call_super(object: Variant, method_name: StringName, args: Array = [])


Method Descriptions๏ƒ

void clear() ๐Ÿ”—

Clears all defined stubs.

After calling this method, no methods will have overridden return values and all behavior will revert to default implementation.


Variant get_return(object: Variant, method_name: StringName, args: Array = []) ๐Ÿ”—

Returns the stubbed return value for a method call.

If a stub exists for the given object, method_name, and optional args, the configured return value is returned.

Otherwise, null is returned or the original method behavior is used depending on context.


void set_return(object: Variant, method_name: StringName, return_value: Variant, args: Variant = null) ๐Ÿ”—

Defines a stubbed return value for a method.

When method_name is called on object, the provided return_value will be returned instead of executing the original method.

If args is specified, the stub only applies when the arguments match.


bool should_call_super(object: Variant, method_name: StringName, args: Array = []) ๐Ÿ”—

Returns whether the original method implementation should still be called.

If true, the stub allows execution of the original method in addition to or instead of returning a stubbed value.

This is useful for partial stubbing or wrapping behavior.