Macros for defining tests scenarios. More...
Scenarios Definitions | |
| #define | TTS_CASE(ID) |
| Introduces a new test scenario and registers it into the current test driver. | |
| #define | TTS_CASE_TPL(ID, ...) |
| Introduces a template test case and registers it into the current test driver. | |
| #define | TTS_CASE_WITH(ID, TYPES, ...) |
| Introduces a template test case providing dynamically generated data to the test code. | |
| #define | TTS_XFAIL(ID) |
| Tags a TTS_CASE (or TTS_CASE_TPL / TTS_CASE_WITH) ID as expected to fail. | |
| #define | TTS_MAYFAIL(ID) |
| Tags a TTS_CASE (or TTS_CASE_TPL / TTS_CASE_WITH) ID as allowed to fail. | |
| #define | TTS_XINVALID(ID) |
| Tags a TTS_CASE (or TTS_CASE_TPL / TTS_CASE_WITH) ID as expected to be empty. | |
Scoped scenarios | |
| #define | TTS_WHEN(STORY) |
| Start a block of scoped environment. | |
| #define | TTS_AND_THEN(MESSAGE) |
| Add a scoped tests to current scoped environment. | |
| #define TTS_AND_THEN | ( | MESSAGE | ) |
#include <tts/test/when.hpp>
Add a scoped tests to current scoped environment.
Compared to regular local scope, whenever a scoped test is run, the data defined in the enclosing TTS_WHEN are re-initialized, thus serving as a setup/tear-down system.
| #define TTS_CASE | ( | ID | ) |
#include <tts/engine/case.hpp>
Introduces a new test scenario and registers it into the current test driver.
The code block following TTS_CASE contains user-defined code for a given test case. Test cases performing no actual tests will be reported as invalid.
| ID | A literal string describing the scenario intents. |
| #define TTS_CASE_TPL | ( | ID, | |
| ... ) |
#include <tts/engine/case.hpp>
Introduces a template test case and registers it into the current test driver.
The code block following TTS_CASE contains user-defined code for a given test case. Those tests are parametrized by a template type of your choice passed as lambda function parameters of the template type tts::type and instantiated for each type in the types list.
Such types list can be provided as:
Test cases performing no actual tests will be reported as invalid.
| ID | A literal string describing the scenario intents. |
| ... | Lists of types to generate the test case from. |
| #define TTS_CASE_WITH | ( | ID, | |
| TYPES, | |||
| ... ) |
#include <tts/engine/case.hpp>
Introduces a template test case providing dynamically generated data to the test code.
The following code block will contain tests parametrized by a template type of your choice passed as lambda function parameters and generated for each type in the types list.
Such types list can be provided as:
Test cases performing no actual tests will be reported as invalid.
| ID | A literal string describing the scenario intents. |
| TYPES | Lists of types to generate the test case from. |
| ... | Lists of generator function |
| #define TTS_MAYFAIL | ( | ID | ) |
#include <tts/engine/case.hpp>
Tags a TTS_CASE (or TTS_CASE_TPL / TTS_CASE_WITH) ID as allowed to fail.
Unlike TTS_XFAIL, nothing specific is expected: the case may pass or fail, either is accepted and neither is reported. Useful for flagging a work-in-progress or a known issue that shouldn't block the suite without pretending to require a specific outcome.
An empty case is still reported, exactly as for an untagged TTS_CASE - TTS_MAYFAIL only relaxes the pass/fail expectation, not the "did anything actually run" one.
| ID | A literal string describing the scenario intents. |
| #define TTS_WHEN | ( | STORY | ) |
#include <tts/test/when.hpp>
Start a block of scoped environment.
Code in a scoped environment can contain:
| #define TTS_XFAIL | ( | ID | ) |
#include <tts/engine/case.hpp>
Tags a TTS_CASE (or TTS_CASE_TPL / TTS_CASE_WITH) ID as expected to fail.
Wraps the case's ID instead of changing the enclosing macro's signature, so it composes with TTS_CASE, TTS_CASE_TPL and TTS_CASE_WITH unchanged: TTS_CASE(TTS_XFAIL("...")).
The case is expected to produce at least one failing assertion. If it runs with no failures instead, that mismatch is reported and fails the suite - matching the "X = expected" naming convention already used by other test frameworks (pytest's xfail, DejaGnu, Perl's Test::More), so it reads the same way to anyone coming from one of those.
An empty case (no assertion ran at all) does not satisfy TTS_XFAIL either - use TTS_XINVALID for that.
| ID | A literal string describing the scenario intents. |
| #define TTS_XINVALID | ( | ID | ) |
#include <tts/engine/case.hpp>
Tags a TTS_CASE (or TTS_CASE_TPL / TTS_CASE_WITH) ID as expected to be empty.
The case is expected to register no assertion at all. If it runs any assertion instead (passing or failing), that mismatch is reported and fails the suite.
| ID | A literal string describing the scenario intents. |