Autowork
Experimental: Some methods may not be implemented and may be changed in future versions.
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) |
get_doubler() const |
|
get_logger() const |
|
get_spy() const |
|
get_stubber() const |
|
get_test_collector() const |
|
void |
|
void |
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.
Returns the total number of assertions executed across all tests.
AutoworkDoubler get_doubler() const 🔗
Returns the AutoworkDoubler instance used for creating test doubles.
Returns the number of tests that have failed.
AutoworkLogger get_logger() const 🔗
Returns the AutoworkLogger instance used by the framework.
Returns the number of tests that have passed successfully.
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.
Returns the total number of tests collected.
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.