CUnit Programmers Reference
3.0
|
Macros | |
#define | automated_run_tests() CU_automated_run_tests() |
Deprecated (version 1). More... | |
#define | set_output_filename(x) CU_set_output_filename((x)) |
Deprecated (version 1). More... | |
Functions | |
CU_EXPORT void | CU_automated_run_tests (void) |
Runs CUnit tests using the automated interface. More... | |
CU_EXPORT CU_ErrorCode | CU_list_tests_to_file (void) |
Generates an xml file containing a list of all tests in all suites in the active registry. More... | |
CU_EXPORT void | CU_set_output_filename (const char *szFilenameRoot) |
Sets the root file name for automated test output files. More... | |
void | CU_automated_package_name_set (const char *pName) |
Set tests suites package name. | |
const char * | CU_automated_package_name_get (void) |
Get tests suites package name. | |
CU_EXPORT void | CCU_automated_add_handlers (void) |
Append the automated (xml) test event handlers. | |
static CU_ErrorCode | automated_list_all_tests (CU_pTestRegistry pRegistry, const char *szFilename) |
Generates an xml listing of all tests in all suites for the specified test registry. More... | |
static CU_ErrorCode | initialize_result_file (const char *szFilename) |
Initializes the test results file generated by the automated interface. More... | |
static CU_ErrorCode | uninitialize_result_file (void) |
Finalizes and closes the results output file generated by the automated interface. | |
static void | automated_run_all_tests (CU_pTestRegistry pRegistry) |
Runs the registered tests using the automated interface. More... | |
static void | automated_test_start_message_handler (const CU_pTest pTest, const CU_pSuite pSuite) |
Handler function called at start of each test. More... | |
static void | automated_test_complete_message_handler (const CU_pTest pTest, const CU_pSuite pSuite, const CU_pFailureRecord pFailure) |
Handler function called at completion of each test. More... | |
static void | automated_test_skipped_message_handler (const CU_pTest pTest, const CU_pSuite pSuite) |
Handler function called when a test is being skipped. More... | |
static void | automated_all_tests_complete_message_handler (const CU_pFailureRecord pFailure) |
Handler function called at completion of all tests in a suite. More... | |
static void | automated_suite_init_failure_message_handler (const CU_pSuite pSuite) |
Handler function called when suite initialization fails. More... | |
static void | automated_suite_cleanup_failure_message_handler (const CU_pSuite pSuite) |
Handler function called when suite cleanup fails. More... | |
void | CU_automated_enable_junit_xml (CU_BOOL bFlag) |
Enable or Disable the XML output format to JUnit-like. More... | |
Variables | |
static CU_pSuite | f_pRunningSuite = NULL |
The running test suite. | |
static char | f_szDefaultFileRoot [] = "CUnitAutomated" |
Default filename root for automated output files. | |
static char | f_szTestListFileName [MAX_FILENAME_LENGTH] = "" |
Current output file name for the test listing file. | |
static char | f_szTestResultFileName [MAX_FILENAME_LENGTH] = "" |
Current output file name for the test results file. | |
static FILE * | f_pTestResultFile = NULL |
FILE pointer the test results file. | |
static CU_BOOL | f_bWriting_CUNIT_RUN_SUITE = CU_FALSE |
Flag for keeping track of when a closing xml tag is required. | |
static CU_BOOL | bJUnitXmlOutput = CU_FALSE |
Flag for toggling the xml junit output or keeping the original. More... | |
#define automated_run_tests | ( | ) | CU_automated_run_tests() |
Deprecated (version 1).
#define set_output_filename | ( | x | ) | CU_set_output_filename((x)) |
Deprecated (version 1).
|
static |
Handler function called at completion of all tests in a suite.
pFailure | Pointer to the test failure record list. |
References bJUnitXmlOutput, CU_get_registry(), and CU_get_run_summary().
Referenced by CCU_automated_add_handlers().
|
static |
Generates an xml listing of all tests in all suites for the specified test registry.
The output is directed to a file having the specified name.
pRegistry | Test registry for which to generate list (non-NULL). |
szFilename | Non-NULL, non-empty string containing name for listing file. |
References CU_set_error(), CUE_BAD_FILENAME, CUE_FOPEN_FAILED, CUE_NOREGISTRY, CUE_SUCCESS, and f_szTestListFileName.
Referenced by CU_list_tests_to_file().
|
static |
Runs the registered tests using the automated interface.
If non-NULL. the specified registry is set as the active registry for running the tests. If NULL, then the default CUnit test registry is used. The actual test running is performed by CU_run_all_tests().
pRegistry | The test registry to run. |
References bJUnitXmlOutput, CU_run_all_tests(), CU_set_registry(), f_pRunningSuite, and f_pTestResultFile.
|
static |
Handler function called when suite cleanup fails.
pSuite | The suite for which cleanup failed. |
References bJUnitXmlOutput, f_bWriting_CUNIT_RUN_SUITE, f_pTestResultFile, and CU_Suite::pName.
Referenced by CCU_automated_add_handlers().
|
static |
Handler function called when suite initialization fails.
pSuite | The suite for which initialization failed. |
References bJUnitXmlOutput, f_bWriting_CUNIT_RUN_SUITE, f_pTestResultFile, and CU_Suite::pName.
Referenced by CCU_automated_add_handlers().
|
static |
Handler function called at completion of each test.
pTest | The test being run (non-NULL). |
pSuite | The suite containing the test (non-NULL). |
pFailure | Pointer to the 1st failure record for this test. |
References bJUnitXmlOutput, CU_FREE, CU_MALLOC, CU_translate_special_characters(), CU_translated_strlen(), f_pTestResultFile, CU_Test::pName, CU_Suite::pName, CU_FailureRecord::pNext, CU_FailureRecord::pSuite, CU_FailureRecord::pTest, CU_FailureRecord::strCondition, CU_FailureRecord::strFileName, CU_FailureRecord::strFunction, and CU_FailureRecord::uiLineNumber.
Referenced by CCU_automated_add_handlers().
|
static |
Handler function called when a test is being skipped.
pTest | The test being skipped (non-NULL). |
pSuite | The suite containing the test (non-NULL). |
References bJUnitXmlOutput, f_pTestResultFile, CU_Test::pName, and CU_Suite::pName.
Referenced by CCU_automated_add_handlers().
|
static |
Handler function called at start of each test.
The test result file must have been opened before this function is called (i.e. f_pTestResultFile non-NULL).
pTest | The test being run (non-NULL). |
pSuite | The suite containing the test (non-NULL). |
References bJUnitXmlOutput, CU_FREE, CU_MALLOC, CU_translate_special_characters(), CU_translated_strlen(), f_bWriting_CUNIT_RUN_SUITE, f_pRunningSuite, f_pTestResultFile, and CU_Suite::pName.
Referenced by CCU_automated_add_handlers().
void CU_automated_enable_junit_xml | ( | CU_BOOL | bFlag | ) |
Enable or Disable the XML output format to JUnit-like.
When enabled (CU_TRUE) then the Results xml that is produced can be read by cruisecontrol and displayed in the test results page.
References bJUnitXmlOutput.
void CU_automated_run_tests | ( | void | ) |
Runs CUnit tests using the automated interface.
This function sets appropriate callback functions, initializes the test output files, and calls the appropriate functions to list the tests and run them. If an output file name root has not been specified using CU_set_output_filename(), a generic root will be applied. It is an error to call this function before the CUnit test registry has been initialized (check by assertion).
References CU_get_registry(), CU_set_output_filename(), CUE_SUCCESS, f_szDefaultFileRoot, f_szTestResultFileName, and initialize_result_file().
CU_ErrorCode CU_list_tests_to_file | ( | void | ) |
Generates an xml file containing a list of all tests in all suites in the active registry.
The output file will be named according to the most recent call to CU_set_output_filename(), or a default if not previously set.
References automated_list_all_tests(), CU_get_registry(), CU_set_output_filename(), f_szDefaultFileRoot, and f_szTestListFileName.
void CU_set_output_filename | ( | const char * | szFilenameRoot | ) |
Sets the root file name for automated test output files.
The strings "-Listing.xml" and "-Results.xml" are appended to the specified root to generate the filenames. If szFilenameRoot is empty, the default root ("CUnitAutomated") is used.
szFilenameRoot | String containing root to use for file names. |
References f_szTestListFileName.
Referenced by CU_automated_run_tests(), and CU_list_tests_to_file().
|
static |
Initializes the test results file generated by the automated interface.
A file stream is opened and header information is written.
References bJUnitXmlOutput, CU_get_error(), CU_set_error(), CUE_BAD_FILENAME, CUE_FCLOSE_FAILED, CUE_FOPEN_FAILED, CUE_SUCCESS, and f_pTestResultFile.
Referenced by CU_automated_run_tests().
|
static |
Flag for toggling the xml junit output or keeping the original.
Off is the default
Referenced by automated_all_tests_complete_message_handler(), automated_run_all_tests(), automated_suite_cleanup_failure_message_handler(), automated_suite_init_failure_message_handler(), automated_test_complete_message_handler(), automated_test_skipped_message_handler(), automated_test_start_message_handler(), CU_automated_enable_junit_xml(), initialize_result_file(), and uninitialize_result_file().