Test Point (old)
Expectation testing is made possible by selective developer instrumentation of the source under test. The instrumentation is unobtrusive and powerful, supporting the ability to optionally attach string or binary data to the Test Point.
API Reference
To specify a test point you should include the srtest.h header file from the STRIDE Runtime in your compilation unit. The Test Point macros are active only when STRIDE_ENABLED is #defined, therefore it is practical to place these macros in-line in production source. When STRIDE_ENABLED is not #defined, these macros evaluate to nothing.
Test Point Macros | |
srTEST_POINT(label) | label is a pointer to a null-terminated string |
srTEST_POINT_DATA(label, data, size) | label is a pointer to a null-terminated string data is a pointer to a byte sequence |
srTEST_POINT_STR(label, message) | label is a pointer to a null-terminated string message is a pointer to a null-terminated string |
srTEST_POINT_STR[1..9](label, message, ...) | label is a pointer to a null-terminated string message is a pointer to a null-terminated format string |
Code Snippets
The source under test is instrumented simply by placing lines of the following form into the source code:
#include <srtest.h>
...
/* a test point with no payload */
srTEST_POINT("first test point");
/* a test point with binary payload */
srTEST_POINT_DATA("second test point", myData, sizeofMyData);
/* a test point with simple string payload */
srTEST_POINT_STR("third test point", "payload with simple string");
/* a test point with formatted string payload */
srTEST_POINT_STR1("third test point", "payload with format string %d", myVar);
#ifdef __cplusplus
srTEST_POINT_STR("c++ test point", "") << "stream input supported under c++";
#endif
When this code is executed it broadcasts a message via the STRIDE Runtime which is detected by the test code if it is currently looking for test points in an expectation test. We refer to the receipt of a test point as a test point hit.