Autowork

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

Inherits: Node < Object

Built-in unit testing framework

Description

The Autowork class provides a native unit testing framework for Blazium Engine.

It allows developers to define, collect, and execute tests directly within the engine using scripts.

It supports common testing features such as assertions, filtering tests, and tracking results (pass, fail, pending).

Additionally, it includes utilities for mocking and observing behavior through components like spies, stubbers, and doublers.

Tests can be automatically discovered from directories or explicitly added scripts.

Once configured, the framework can execute all collected tests and provide detailed statistics and logging.

Tutorials

Methods

void

add_directory(path: String, prefix: String = "", suffix: String = "")

void

add_script(path: String)

int

get_assert_count()

AutoworkDoubler

get_doubler() const

int

get_fail_count()

AutoworkLogger

get_logger() const

int

get_pass_count()

int

get_pending_count()

AutoworkSpy

get_spy() const

AutoworkStubber

get_stubber() const

AutoworkCollector

get_test_collector() const

int

get_test_count()

int

get_test_script_count()

void

run_tests()

void

set_test(test_name: String)


Method Descriptions

void add_directory(path: String, prefix: String = "", suffix: String = "") 🔗

Adds a directory to be scanned for test scripts.

All scripts in the given path are evaluated and included if they match the configured naming rules.

The optional prefix and suffix parameters can be used to override the default naming convention for test discovery.

If prefix or suffix are empty, the globally configured defaults are used instead.


void add_script(path: String) 🔗

Adds a single script file to the test suite.

The script located at path is parsed and any test cases defined within it are registered for execution.


int get_assert_count() 🔗

Returns the total number of assertions executed across all tests.


AutoworkDoubler get_doubler() const 🔗

Returns the AutoworkDoubler instance used for creating test doubles.


int get_fail_count() 🔗

Returns the number of tests that have failed.


AutoworkLogger get_logger() const 🔗

Returns the AutoworkLogger instance used by the framework.


int get_pass_count() 🔗

Returns the number of tests that have passed successfully.


int get_pending_count() 🔗

Returns the number of tests that are marked as pending.


AutoworkSpy get_spy() const 🔗

Returns the AutoworkSpy instance used for observing function calls.


AutoworkStubber get_stubber() const 🔗

Returns the AutoworkStubber instance used for defining stubbed behavior.


AutoworkCollector get_test_collector() const 🔗

Returns the AutoworkCollector responsible for managing discovered tests.


int get_test_count() 🔗

Returns the total number of tests collected.


int get_test_script_count() 🔗

Returns the number of scripts that contain tests.


void run_tests() 🔗

Executes all collected tests.


void set_test(test_name: String) 🔗

Sets a filter pattern to determine which tests should be executed.