The Test Cases Reference
Test cases are named sequences of checks. More...
Functions Index
void | test_case (const char *name, Callable_T &&callable, Args_T &&... arguments) |
Define and execute a test case. More... | |
Description
Test cases are named sequences of checks.
Test cases in µTest++ are named collections of checks that are executed within the same environment. Each test case is defined by providing a descriptive name and a callable object (typically a lambda), along with any optional arguments required for the test.
Test cases enable developers to organise related checks together, improving the clarity and maintainability of the test suite. Any number of test cases may be defined, each focusing on a specific aspect of the code under test.
By grouping checks in this way, it becomes easier to identify which functionality is being verified and to interpret the results in the context of the overall software quality.
- Examples
Functions
test_case()
|
Define and execute a test case.
- Template Parameters
Callable_T The type of the callable object to be executed as the test case. Args_T The types of the arguments to be passed to the callable.
- Parameters
[in] name The test case name or description, used in test reports. [in] callable A generic callable object, usually a lambda, invoked to perform the test. [in] arguments A possibly empty list of arguments to be passed to the callable.
- Returns
Nothing.
The test_case
function template registers and executes a test case within the µTest++ framework. It accepts a descriptive name, a callable object (such as a lambda or function pointer), and an optional list of arguments to be passed to the callable. The test case is reported using the provided name, and its execution is managed by the framework's test runner.
Each test case typically involves evaluating a logical expression, such as comparing a computed result to an expected value. For C++ projects, it is also possible to verify whether evaluating an expression throws exceptions. Each test either succeeds or fails, and for expectations, the test runner maintains counts of successful and failed checks.
This function template enables flexible and expressive test case definitions, supporting both parameterised and non-parameterised tests. It is typically invoked at global scope or within test suite definitions to ensure automatic registration and execution.
A test case is characterised by a name, a function that performs the checks, and optionally, arguments to be passed to that function. The implementation of test_case
invokes the provided function with the given arguments and reports the results to the test runner.
- Example
Definition at line 114 of file micro-test-plus-inlines.h.
Generated via docusaurus-plugin-doxygen by Doxygen 1.14.0.