CUnit Programmers Reference
3.0
|
Management functions for tests, suites, and the test registry. More...
#include <setjmp.h>
#include "CUnit/CUnit.h"
#include "CUnit/CUError.h"
#include "CUnit/Simple.h"
#include "CUnit/TestFixture.h"
Go to the source code of this file.
Data Structures | |
struct | CU_Test |
CUnit test case data type. More... | |
struct | CU_Suite |
CUnit suite data type. More... | |
struct | CU_TestRegistry |
CUnit test registry data type. More... | |
struct | CU_TestInfo |
Test case parameters structure. More... | |
struct | CU_SuiteInfo |
Suite parameters. More... | |
struct | test_suite |
Deprecated (version 1). More... | |
Macros | |
#define | CU_ADD_TEST(suite, test) (CU_add_test(suite, #test, (CU_TestFunc)test)) |
Shortcut macro for adding a test to a suite. | |
#define | CU_TEST_INFO_NULL { NULL, NULL } |
NULL CU_test_info_t to terminate arrays of tests. | |
#define | CU_SUITE_INFO_NULL { NULL, NULL, NULL, NULL, NULL, NULL } |
NULL CU_suite_info_t to terminate arrays of suites. | |
#define | TEST_CASE_NULL { NULL, NULL } |
Deprecated (version 1). More... | |
#define | TEST_GROUP_NULL { NULL, NULL, NULL, NULL } |
Deprecated (version 1). More... | |
#define | test_group_register(tg) CU_register_suites(tg) |
Deprecated (version 1). More... | |
#define | initialize_registry() CU_initialize_registry() |
Deprecated (version 1). More... | |
#define | cleanup_registry() CU_cleanup_registry() |
Deprecated (version 1). More... | |
#define | add_test_group(name, init, clean) CU_add_suite(name, init, clean) |
Deprecated (version 1). More... | |
#define | add_test_case(group, name, test) CU_add_test(group, name, test) |
Deprecated (version 1). More... | |
#define | get_registry() CU_get_registry() |
Deprecated (version 1). More... | |
#define | set_registry(reg) CU_set_registry((reg)) |
Deprecated (version 1). More... | |
#define | get_group_by_name(group, reg) CU_get_suite_by_name(group, reg) |
Deprecated (version 1). More... | |
#define | get_test_by_name(test, group) CU_get_test_by_name(test, group) |
Deprecated (version 1). More... | |
#define | ADD_TEST_TO_GROUP(group, test) (CU_add_test(group, #test, (CU_TestFunc)test)) |
Deprecated (version 1). More... | |
Typedefs | |
typedef struct CU_Test | CU_Test |
CUnit test case data type. More... | |
typedef CU_Test * | CU_pTest |
Pointer to a CUnit test case. | |
typedef struct CU_Suite | CU_Suite |
CUnit suite data type. More... | |
typedef CU_Suite * | CU_pSuite |
Pointer to a CUnit suite. | |
typedef struct CU_TestRegistry | CU_TestRegistry |
CUnit test registry data type. More... | |
typedef CU_TestRegistry * | CU_pTestRegistry |
Pointer to a CUnit test registry. | |
typedef struct CU_TestInfo | CU_TestInfo |
Test case parameters structure. More... | |
typedef CU_TestInfo * | CU_pTestInfo |
Pointer to CU_TestInfo type. | |
typedef struct CU_SuiteInfo | CU_SuiteInfo |
Suite parameters. More... | |
typedef CU_SuiteInfo * | CU_pSuiteInfo |
Pointer to CU_SuiteInfo type. | |
typedef CU_TestInfo | test_case_t |
Deprecated (version 1). More... | |
typedef CU_SuiteInfo | test_group_t |
Deprecated (version 1). More... | |
typedef struct test_suite | test_suite_t |
Deprecated (version 1). More... | |
typedef CU_InitializeFunc | InitializeFunc |
Deprecated (version 1). More... | |
typedef CU_CleanupFunc | CleanupFunc |
Deprecated (version 1). More... | |
typedef CU_TestFunc | TestFunc |
Deprecated (version 1). More... | |
typedef CU_Test | _TestCase |
Deprecated (version 1). More... | |
typedef CU_pTest | PTestCase |
Deprecated (version 1). More... | |
typedef CU_Suite | _TestGroup |
Deprecated (version 1). More... | |
typedef CU_pSuite | PTestGroup |
Deprecated (version 1). More... | |
typedef CU_TestRegistry | _TestRegistry |
Deprecated (version 1). More... | |
typedef CU_pTestRegistry | PTestRegistry |
Deprecated (version 1). More... | |
Functions | |
CU_EXPORT CU_ErrorCode | CU_initialize_registry (void) |
Initializes the framework test registry. More... | |
CU_EXPORT void | CU_sort_suites (CU_pTestRegistry pRegistry) |
Sort the registered test suites into alphabetical order. More... | |
CU_EXPORT void | CU_cleanup_registry (void) |
Clears the test registry. More... | |
CU_EXPORT CU_BOOL | CU_registry_initialized (void) |
Checks whether the test registry has been initialized. More... | |
CU_EXPORT CU_pSuite | CU_add_suite (const char *strName, CU_InitializeFunc pInit, CU_CleanupFunc pClean) |
Creates a new test suite and adds it to the test registry. More... | |
CU_EXPORT CU_pSuite | CU_add_suite_with_setup_and_teardown (const char *strName, CU_InitializeFunc pInit, CU_CleanupFunc pClean, CU_SetUpFunc pSetup, CU_TearDownFunc pTear) |
The same as CU_add_suite but also adds setup and tear down callbacks for each test in this suite. More... | |
CU_EXPORT CU_ErrorCode | CU_set_suite_active (CU_pSuite pSuite, CU_BOOL fNewActive) |
Activates or deactivates a suite. More... | |
CU_EXPORT CU_ErrorCode | CU_set_suite_name (CU_pSuite pSuite, const char *strNewName) |
Modifies the name of a suite. More... | |
CU_EXPORT CU_ErrorCode | CU_set_suite_initfunc (CU_pSuite pSuite, CU_InitializeFunc pNewInit) |
Modifies the initialization function of a suite. More... | |
CU_EXPORT CU_ErrorCode | CU_set_suite_cleanupfunc (CU_pSuite pSuite, CU_CleanupFunc pNewClean) |
Modifies the cleanup function of a suite. More... | |
CU_EXPORT CU_pSuite | CU_get_suite (const char *strName) |
Retrieves the suite having the specified name. More... | |
CU_EXPORT CU_pSuite | CU_get_suite_at_pos (unsigned int pos) |
Retrieves the suite at the specified position. More... | |
CU_EXPORT unsigned int | CU_get_suite_pos (CU_pSuite pSuite) |
Looks up the position of the specified suite. More... | |
CU_EXPORT unsigned int | CU_get_suite_pos_by_name (const char *strName) |
Looks up the position of the suite having the specified name. More... | |
CU_EXPORT CU_pTest | CU_add_test (CU_pSuite pSuite, const char *strName, CU_TestFunc pTestFunc) |
This function creates a new test having the specified name and function, and adds it to the specified suite. More... | |
CU_EXPORT CU_ErrorCode | CU_set_test_active (CU_pTest pTest, CU_BOOL fNewActive) |
Activates or deactivates a specific test. More... | |
CU_EXPORT CU_ErrorCode | CU_set_test_name (CU_pTest pTest, const char *strNewName) |
Modifies the name of a test. More... | |
CU_EXPORT CU_ErrorCode | CU_set_test_func (CU_pTest pTest, CU_TestFunc pNewFunc) |
Modifies the test function of a test. More... | |
CU_EXPORT CU_pTest | CU_get_test (CU_pSuite pSuite, const char *strName) |
Retrieves the test having the specified name. More... | |
CU_EXPORT CU_pTest | CU_get_test_at_pos (CU_pSuite pSuite, unsigned int pos) |
Retrieves the test at the specified position in pSuite. More... | |
CU_EXPORT unsigned int | CU_get_test_pos (CU_pSuite pSuite, CU_pTest pTest) |
Looks up the position of the specified test in pSuite. More... | |
CU_EXPORT unsigned int | CU_get_test_pos_by_name (CU_pSuite pSuite, const char *strName) |
Looks up the position of the test having the specified name in pSuite. More... | |
CU_EXPORT CU_ErrorCode | CU_set_all_active (CU_BOOL fNewActive) |
Activates or deactivates all tests. More... | |
CU_EXPORT CU_ErrorCode | CU_register_suites (CU_SuiteInfo suite_info[]) |
Registers the suites in a single CU_SuiteInfo array. More... | |
CU_EXPORT CU_ErrorCode | CU_register_nsuites (int suite_count,...) |
Registers multiple suite arrays in CU_SuiteInfo format. More... | |
CU_EXPORT int | test_suite_register (test_suite_t *ts) |
Deprecated (version 1). More... | |
CU_EXPORT CU_pTestRegistry | CU_get_registry (void) |
Retrieves a pointer to the current test registry. More... | |
CU_EXPORT CU_pTestRegistry | CU_set_registry (CU_pTestRegistry pTestRegistry) |
Sets the registry to an existing CU_pTestRegistry instance. More... | |
CU_EXPORT CU_pTestRegistry | CU_create_new_registry (void) |
Creates and initializes a new test registry. More... | |
CU_EXPORT void | CU_destroy_existing_registry (CU_pTestRegistry *ppRegistry) |
Destroys and frees all memory for an existing test registry. More... | |
CU_EXPORT CU_pSuite | CU_get_suite_by_name (const char *szSuiteName, CU_pTestRegistry pRegistry) |
Retrieves a pointer to the suite having the specified name. More... | |
CU_EXPORT CU_pSuite | CU_get_suite_by_index (unsigned int index, CU_pTestRegistry pRegistry) |
Retrieves a pointer to the suite at the specified (1-based) index. More... | |
CU_EXPORT CU_pTest | CU_get_test_by_name (const char *szTestName, CU_pSuite pSuite) |
Retrieves a pointer to the test case in pSuite having the specified name. More... | |
CU_EXPORT CU_pTest | CU_get_test_by_index (unsigned int index, CU_pSuite pSuite) |
Retrieves a pointer to the test at the specified (1-based) index. More... | |
Management functions for tests, suites, and the test registry.
Unit testing in CUnit follows the common structure of unit tests aggregated in suites, which are themselves aggregated in a test registry. This module provides functions and typedef's to support the creation, registration, and manipulation of test cases, suites, and the registry.