PicoTest
A minimalist unit testing framework for C programs
|
Test Fixture Hooks | |
PicoTest provides a way for client code to intercept test fixture events. This can be used for e.g. logging purpose or reporting. | |
typedef void | PicoTestFixtureBeforeSetupProc(const char *fixtureName, const char *testName) |
Function signature of test fixture before setup hooks. | |
typedef void | PicoTestFixtureAfterSetupProc(const char *fixtureName, const char *testName) |
Function signature of test fixture after setup hooks. | |
typedef void | PicoTestFixtureBeforeTeardownProc(const char *fixtureName, const char *testName, int fail) |
Function signature of test fixture before teardown hooks. | |
typedef void | PicoTestFixtureAfterTeardownProc(const char *fixtureName, const char *testName, int fail) |
Function signature of test fixture after teardown hooks. | |
#define | PICOTEST_FIXTURE_BEFORE_SETUP_DEFAULT(fixtureName, testName) |
Default test fixture before setup hook. | |
#define | PICOTEST_FIXTURE_BEFORE_SETUP |
Define the test fixture before setup hook. | |
#define | PICOTEST_FIXTURE_AFTER_SETUP_DEFAULT(fixtureName, testName) |
Default test fixture after setup hook. | |
#define | PICOTEST_FIXTURE_AFTER_SETUP |
Define the test fixture after setup hook. | |
#define | PICOTEST_FIXTURE_BEFORE_TEARDOWN_DEFAULT(fixtureName, testName, fail) |
Default test fixture before teardown hook. | |
#define | PICOTEST_FIXTURE_BEFORE_TEARDOWN |
Define the test fixture before teardown hook. | |
#define | PICOTEST_FIXTURE_AFTER_TEARDOWN_DEFAULT(fixtureName, testName, fail) |
Default test fixture after teardown hook. | |
#define | PICOTEST_FIXTURE_AFTER_TEARDOWN |
Define the test fixture after teardown hook. |
Test Fixture Definitions | |
#define | PICOTEST_FIXTURE_CONTEXT(_fixtureName) |
Test fixture context declaration. | |
#define | PICOTEST_FIXTURE_SETUP(...) |
Test fixture initialization. | |
#define | PICOTEST_FIXTURE_TEARDOWN(...) |
Test fixture cleanup. |
Test fixtures are used to establish the context needed to run test cases.
A test fixture can be used by several, possibly unrelated test cases.
#define PICOTEST_FIXTURE_CONTEXT | ( | _fixtureName | ) |
Test fixture context declaration.
Fixtures can optionally define a context structure that is passed to its setup and teardown functions.
_fixtureName | Name of the fixture. |
#define PICOTEST_FIXTURE_SETUP | ( | ... | ) |
Test fixture initialization.
_fixtureName | Name of the fixture. |
_context | (optional) Fixture context structure defined using PICOTEST_FIXTURE_CONTEXT(_fixtureName). |
A more complex example with a context structure:
Fixtures may define an optional context that test cases don't need, in this case the context passed to the setup and teardown functions is NULL:
Here is an example of such a test case:
#define PICOTEST_FIXTURE_TEARDOWN | ( | ... | ) |
Test fixture cleanup.
_fixtureName | Name of the fixture. |
_context | (optional) Fixture context structure defined using PICOTEST_FIXTURE_CONTEXT(_fixtureName). |
A more complex example with a context structure:
Fixtures may define an optional context that test cases don't need, in this case the context passed to the setup and teardown functions is NULL:
Here is an example of such a test case:
#define PICOTEST_FIXTURE_BEFORE_SETUP_DEFAULT | ( | fixtureName, | |
testName ) |
Default test fixture before setup hook.
Does nothing.
#define PICOTEST_FIXTURE_BEFORE_SETUP |
Define the test fixture before setup hook.
The default hook does nothing. Redefine this macro to use a custom hook, which must follow the PicoTestFixtureBeforeSetupProc signature.
#define PICOTEST_FIXTURE_AFTER_SETUP_DEFAULT | ( | fixtureName, | |
testName ) |
Default test fixture after setup hook.
Does nothing.
#define PICOTEST_FIXTURE_AFTER_SETUP |
Define the test fixture after setup hook.
The default hook does nothing. Redefine this macro to use a custom hook, which must follow the PicoTestFixtureAfterSetupProc signature.
#define PICOTEST_FIXTURE_BEFORE_TEARDOWN_DEFAULT | ( | fixtureName, | |
testName, | |||
fail ) |
Default test fixture before teardown hook.
Does nothing.
#define PICOTEST_FIXTURE_BEFORE_TEARDOWN |
Define the test fixture before teardown hook.
The default hook does nothing. Redefine this macro to use a custom hook, which must follow the PicoTestFixtureBeforeTeardownProc signature.
#define PICOTEST_FIXTURE_AFTER_TEARDOWN_DEFAULT | ( | fixtureName, | |
testName, | |||
fail ) |
Default test fixture after teardown hook.
Does nothing.
#define PICOTEST_FIXTURE_AFTER_TEARDOWN |
Define the test fixture after teardown hook.
The default hook does nothing. Redefine this macro to use a custom hook, which must follow the PicoTestFixtureAfterTeardownProc signature.
typedef void PicoTestFixtureBeforeSetupProc(const char *fixtureName, const char *testName) |
Function signature of test fixture before setup hooks.
Called before running the test fixture setup.
fixtureName | Test fixture name. |
testName | Test case name. |
typedef void PicoTestFixtureAfterSetupProc(const char *fixtureName, const char *testName) |
Function signature of test fixture after setup hooks.
Called after running the test fixture setup.
fixtureName | Test fixture name. |
testName | Test case name. |
typedef void PicoTestFixtureBeforeTeardownProc(const char *fixtureName, const char *testName, int fail) |
Function signature of test fixture before teardown hooks.
Called before running the test fixture teardown.
fixtureName | Test fixture name. |
testName | Test case name. |
fail | Failed tests (including its subtests if any). |
typedef void PicoTestFixtureAfterTeardownProc(const char *fixtureName, const char *testName, int fail) |
Function signature of test fixture after teardown hooks.
Called after running the test fixture teardown.
fixtureName | Test fixture name. |
testName | Test case name. |
fail | Failed tests (including its subtests if any). |