Class TestingFixture¶
Defined in File TestingFixture.hpp
Class Documentation¶
-
class TestingFixture¶
[source] Encapsulates an isolated Registry, Output, and Result for running tests inside other tests.
TestingFixture is used to test the mutiny framework itself. It owns a private Registry and StringBufferOutput so that tests run through it do not affect the global Registry or console output.
Public Functions
-
void install_plugin(Plugin *plugin)¶
Install
plugininto the private Registry.- Parameters:
plugin – Plugin to install.
-
void set_test_function(void (*test_function)())¶
Set the test body to a plain function pointer.
- Parameters:
test_function – Function to invoke as the test body.
-
void set_test_function(ExecFunction *test_function)¶
Set the test body to an ExecFunction.
- Parameters:
test_function – ExecFunction whose exec() is the test body.
-
void set_setup(void (*setup_function)())¶
Set the setup function run before each test body.
- Parameters:
setup_function – Function to invoke as setup.
-
void set_teardown(void (*teardown_function)())¶
Set the teardown function run after each test body.
- Parameters:
teardown_function – Function to invoke as teardown.
-
void run_test_with_method(void (*method)())¶
Run the single test set by set_test_function() with
methodas its body.- Parameters:
method – Body to execute inside the test.
-
void assert_print_contains(const String &contains)¶
Assert that the output buffer contains
contains.- Parameters:
contains – Substring expected in the output.
-
void assert_print_contains_not(const String &contains)¶
Assert that the output buffer does not contain
contains.- Parameters:
contains – Substring that must be absent from the output.
-
void check_test_fails_with_proper_test_location(const char *text, const char *file, int_least32_t line)¶
Run a test that is expected to fail and verify the failure message.
- Parameters:
text – Expected substring of the failure message.
file – Expected source file in the failure location.
line – Expected line number in the failure location.
Public Static Functions
-
static void line_executed_after_check()¶
[source] Sentinel that must be called to prove execution continued past a check.
Call this immediately after an assertion macro in a test that uses TestingFixture; the fixture verifies it was reached.
Protected Functions
-
void replace_output(StringBufferOutput *new_output)¶
Swap in a different output object.
- Parameters:
new_output – New output to use; the fixture takes ownership.
-
void install_plugin(Plugin *plugin)¶