|
Unit Test Framework C and Traditional C++ API Reference
|
Provides the infrastructure to set up recursive module testing. See the user's manual for examples of how to use most of these APIs. More...
Macros | |
| #define | RTITestSetting_getTestCount(testArray) (sizeof((testArray)) / sizeof(RTITestFunction)) |
| Get the number of tests in the test array. More... | |
Typedefs | |
| typedef RTITestReturnCode(* | RTITestFunction) (const struct RTITestSetting *setting) |
| Function prototype for all tests. More... | |
Functions | |
| RTIBool | RTITestSetting_parseArgument (struct RTITestSetting *setting, int argCount, char **argv) |
Parses command-line arguments to initialize an RTITestSetting structure. More... | |
| void | RTITestSetting_getRange (const struct RTITestSetting *setting, int *begin, int *end, RTITestLevel currentLevel) |
| Given the test setting and the test level, this function extracts the index of the first and last test at that level. More... | |
| RTITestReturnCode | RTITestSetting_runTests (const struct RTITestSetting *setting, const char *methodName, const RTITestFunction *test, int testCount, int begin, int end) |
| Given a set of tests and a test setting, run a subset of these tests with that test setting. More... | |
| void | RTITestSetting_printComplete (const char *methodName) |
| Printout to indicate completion of a Tester. More... | |
| void | RTITestSetting_init (struct RTITestSetting *setting) |
| Fill setting with default values. More... | |
| int | RTITestSetting_enableHeapMonitoringSupport (void) |
| Enables heap monitoring support. More... | |
| void | RTITestSetting_disableHeapMonitoringSupport (int *ok) |
| Disables heap monitoring support and checks if there are memory leaks. More... | |
| int | RTITestSetting_getCurrentNumberOfRetries (void) |
| Get the current number of retries. More... | |
Provides the infrastructure to set up recursive module testing. See the user's manual for examples of how to use most of these APIs.
Many of the functions documented here are required to be called in the main Tester and TestSuite run methods; a deep understanding of exactly what they do is not needed. An example skeleton of a Tester run method is as follows:
The only difference between the above method and a TestSuite run method is that a TestSuite method should not call RTITestSetting_printComplete() and the fourth argument passed to RTITestSetting_getRange() should be RTI_TEST_LEVEL_UNIT.
| #define RTITestSetting_getTestCount | ( | testArray | ) | (sizeof((testArray)) / sizeof(RTITestFunction)) |
Get the number of tests in the test array.
| typedef RTITestReturnCode(* RTITestFunction) (const struct RTITestSetting *setting) |
Function prototype for all tests.
All tests (module test, submodule test or unit test) use this function prototype. This allows grouping them in arrays for recursive execution.
The RTITestSetting parameter is specified at the module test level and passed down via the submodule tests to the unit tests.
| setting | In. Pointer to the test setting information. |
| up | to the implementer. |
| RTIBool RTITestSetting_parseArgument | ( | struct RTITestSetting * | setting, |
| int | argCount, | ||
| char ** | argv | ||
| ) |
Parses command-line arguments to initialize an RTITestSetting structure.
This function is only useful on platforms supporting main() as the entry point.
Example usage:
Run your program with the argument -help to check the available arguments and a brief description of the effect of each of them.
RTITestSetting_parseArgument() automatically prints a usage message if it cannot successfully parse all command-line arguments.
| setting | Out. "this" pointer. The command-line arguments will be written to this RTITestSetting struct. |
| argCount | In. First parameter of main() entry point. |
| argv | In. Second parameter of main() entry point. |
| void RTITestSetting_getRange | ( | const struct RTITestSetting * | setting, |
| int * | begin, | ||
| int * | end, | ||
| RTITestLevel | currentLevel | ||
| ) |
Given the test setting and the test level, this function extracts the index of the first and last test at that level.
The test setting contains the begin and end test numbers, both at the unit test and submodule test level. This function extracts those numbers. Use the currentLevel parameter to specify which level you need the information for.
| setting | In. "this" pointer. The test setting that contains the info. |
| begin | Out. Pointer to begin answer. |
| end | Out. Pointer to end answer. |
| currentLevel | In. Level at which the info must be obtained. |
| RTITestReturnCode RTITestSetting_runTests | ( | const struct RTITestSetting * | setting, |
| const char * | methodName, | ||
| const RTITestFunction * | test, | ||
| int | testCount, | ||
| int | begin, | ||
| int | end | ||
| ) |
Given a set of tests and a test setting, run a subset of these tests with that test setting.
The set of tests is passed as an array of RTITestFunction function pointers. The subset of tests to run is specified as a range of array indices, from index begin to index end.
Negative indices in the range are interpreted as first and last test respectively. All other indices outside of the array bounds are ignored.
| setting | In. "this". Run applicable tests with this setting (passed as a parameter to each test). |
| methodName | In. Name of the module or submodule that is firing off the batch test. Used for generating warning or error messages. |
| test | In. Array of tests, as function pointers. |
| testCount | In. Size of the test array. This includes any NULL entries, which will be skipped. |
| begin | In. The array index of the first test to run. A negative number will be set to zero. |
| end | In. The array index of the last test to run. A negative number will be set to testCount-1. |
| void RTITestSetting_printComplete | ( | const char * | methodName | ) |
Printout to indicate completion of a Tester.
| void RTITestSetting_init | ( | struct RTITestSetting * | setting | ) |
Fill setting with default values.
Override the values you are interested in after this. This function should be called in the test executable main function before RTITestSetting_parseArgument().
| setting | Out. The setting to initialize |
| int RTITestSetting_enableHeapMonitoringSupport | ( | void | ) |
Enables heap monitoring support.
When the command-line option -enableHeapMonitoring is used, the field enableHeapMonitoring in the RTITestSetting structure will be set to RTI_TRUE. The tester_run function in a module should call this API to enable support for heap monitoring. For example:
The function must be called at the very beginning of the test before doing any DDS calls.
If the function is not called and the command-line option enableHeapMonitoring is used, the test will fail indicating that heap monitoring has not been enabled.
| void RTITestSetting_disableHeapMonitoringSupport | ( | int * | ok | ) |
Disables heap monitoring support and checks if there are memory leaks.
When the command-line option enableHeapMonitoring is used, this function must be called at the end of a tester_run function in a module to disable support for heap monitoring.
For example
If there are memory leaks, ok is set to RTI_FALSE and an exception is logged.
| ok | Out. It will be set to 0 if there are memory leaks. |
| int RTITestSetting_getCurrentNumberOfRetries | ( | void | ) |
Get the current number of retries.
The maxRetries option allows you to retry a failed test until it succeeds or until the maximum retry number specifed with this argument is reached. This function returns the current number of times a test has been retried so far. A value of zero means that the test is being run for the first time.