CUnit Programmers Reference  3.0
Functions | Variables
TestRun.c File Reference

Test run management functions (implementation). More...

#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <setjmp.h>
#include <time.h>
#include "CUnit/CUnit.h"
#include "CUnit/MyMem.h"
#include "CUnit/TestDB.h"
#include "CUnit/TestRun.h"
#include "CUnit/MessageHandlers.h"
#include "CUnit/Util.h"
#include "CUnit/CUnit_intl.h"

Functions

static void clear_previous_results (CU_pRunSummary pRunSummary, CU_pFailureRecord *ppFailure)
 Initializes the run summary information in the specified structure. More...
 
static void cleanup_failure_list (CU_pFailureRecord *ppFailure)
 Frees all memory allocated for the linked list of test failure records. More...
 
static CU_ErrorCode run_single_suite (CU_pSuite pSuite, CU_pRunSummary pRunSummary)
 Runs all tests in a specified suite. More...
 
static CU_ErrorCode run_single_test (CU_pTest pTest, CU_pRunSummary pRunSummary)
 Runs a specific test. More...
 
static void add_failure (CU_pFailureRecord *ppFailure, CU_pRunSummary pRunSummary, CU_FailureType type, unsigned int uiLineNumber, const char *szCondition, const char *szFileName, const char *szFunction, CU_pSuite pSuite, CU_pTest pTest)
 Records a runtime failure. More...
 
CU_EXPORT CU_BOOL CU_assertImplementation (CU_BOOL bValue, unsigned int uiLine, const char *strCondition, const char *strFile, const char *strFunction, CU_BOOL bFatal)
 Assertion implementation function. More...
 
CU_EXPORT void CU_SkipImplementation (CU_BOOL bValue, unsigned int uiLine, const char *strCondition, const char *strFile, const char *strFunction)
 Skip Implementation Called to skip execution of current test or current suite. More...
 
CU_EXPORT void CU_set_suite_start_handler (CU_SuiteStartMessageHandler pSuiteStartMessage)
 Sets the message handler to call before each suite is run.
 
CU_EXPORT void CU_set_test_start_handler (CU_TestStartMessageHandler pTestStartMessage)
 Sets the message handler to call before each test is run.
 
CU_EXPORT void CU_set_test_complete_handler (CU_TestCompleteMessageHandler pTestCompleteMessage)
 Sets the message handler to call after each test is run.
 
CU_EXPORT void CU_set_test_skipped_handler (CU_TestSkippedMessageHandler pTestSkippedMessage)
 Sets the message handler to call when a test is skipped.
 
CU_EXPORT void CU_set_suite_complete_handler (CU_SuiteCompleteMessageHandler pSuiteCompleteMessage)
 Sets the message handler to call after each suite is run.
 
CU_EXPORT void CU_set_all_test_complete_handler (CU_AllTestsCompleteMessageHandler pAllTestsCompleteMessage)
 Sets the message handler to call after all tests have been run.
 
CU_EXPORT void CU_set_suite_init_failure_handler (CU_SuiteInitFailureMessageHandler pSuiteInitFailureMessage)
 Sets the message handler to call when a suite initialization function returns an error.
 
CU_EXPORT void CU_set_suite_cleanup_failure_handler (CU_SuiteCleanupFailureMessageHandler pSuiteCleanupFailureMessage)
 Sets the message handler to call when a suite cleanup function returns an error.
 
CU_EXPORT void CU_set_suite_skipped_handler (CU_SuiteSkippedMessageHandler pSuiteSkipped)
 Sets the message handler to call when a suite is skipped.
 
CU_EXPORT double CU_get_test_duration (CU_pTest pTest)
 
CU_EXPORT double CU_get_suite_duration (CU_pSuite pSuite)
 
CU_EXPORT unsigned int CU_get_number_of_suites_run (void)
 Retrieves the number of suites completed during the previous run (reset each run).
 
CU_EXPORT unsigned int CU_get_number_of_suites_failed (void)
 Retrieves the number of suites which failed to initialize during the previous run (reset each run).
 
CU_EXPORT unsigned int CU_get_number_of_suites_inactive (void)
 Retrieves the number of inactive suites found during the previous run (reset each run).
 
CU_EXPORT unsigned int CU_get_number_of_tests_run (void)
 Retrieves the number of tests completed during the previous run (reset each run).
 
CU_EXPORT unsigned int CU_get_number_of_tests_failed (void)
 Retrieves the number of tests containing failed assertions during the previous run (reset each run).
 
CU_EXPORT unsigned int CU_get_number_of_tests_inactive (void)
 Retrieves the number of inactive tests found during the previous run (reset each run).
 
CU_EXPORT unsigned int CU_get_number_of_asserts (void)
 Retrieves the number of assertions processed during the last run (reset each run).
 
CU_EXPORT unsigned int CU_get_number_of_successes (void)
 Retrieves the number of successful assertions during the last run (reset each run).
 
CU_EXPORT unsigned int CU_get_number_of_failures (void)
 Retrieves the number of failed assertions during the last run (reset each run).
 
CU_EXPORT unsigned int CU_get_number_of_failure_records (void)
 Retrieves the number failure records created during the previous run (reset each run). More...
 
CU_EXPORT double CU_get_elapsed_time (void)
 Retrieves the elapsed time for the last run in seconds (reset each run). More...
 
CU_EXPORT CU_pFailureRecord CU_get_failure_list (void)
 Retrieves the head of the linked list of failures which occurred during the last run (reset each run). More...
 
CU_EXPORT int CU_count_test_failures (CU_pTest pTest)
 Count the number of failures from the given test. More...
 
CU_EXPORT int CU_count_suite_failures (CU_pSuite pSuite)
 Count the number of failed tests in a suite. More...
 
CU_EXPORT int CU_count_all_tests (CU_pTestRegistry pRegistry)
 Count the number of tests in a suite. More...
 
CU_EXPORT int CU_count_all_failures (CU_pTestRegistry pRegistry)
 Count the number of failed tests overall. More...
 
CU_EXPORT CU_pFailureRecord CU_iterate_test_failures (CU_pTest test, CU_pFailureRecord previous)
 Iterate over the recorded failure records of a given test. More...
 
CU_EXPORT CU_pRunSummary CU_get_run_summary (void)
 Count the number of tests in all suites. More...
 
CU_EXPORT CU_ErrorCode CU_run_all_tests (void)
 Runs all tests in all suites registered in the test registry. More...
 
CU_EXPORT CU_ErrorCode CU_run_suite (CU_pSuite pSuite)
 Runs all tests in a specified suite. More...
 
CU_EXPORT CU_ErrorCode CU_run_test (CU_pSuite pSuite, CU_pTest pTest)
 Runs a specific test in a specified suite. More...
 
CU_EXPORT void CU_clear_previous_results (void)
 Initializes the run summary information stored from the previous test run. More...
 
CU_EXPORT CU_pSuite CU_get_current_suite (void)
 Retrieves a pointer to the currently-running suite (NULL if none).
 
CU_EXPORT CU_pTest CU_get_current_test (void)
 Retrievea a pointer to the currently-running test (NULL if none).
 
CU_EXPORT CU_BOOL CU_is_test_running (void)
 Returns CU_TRUE if a test run is in progress, CU_TRUE otherwise.
 
CU_EXPORT void CU_set_fail_on_inactive (CU_BOOL new_inactive)
 Sets whether an inactive suite or test is treated as a failure. More...
 
CU_EXPORT CU_BOOL CU_get_fail_on_inactive (void)
 Retrieves the current setting for whether inactive suites/tests are treated as failures. More...
 
CU_EXPORT void CU_print_run_results (FILE *file)
 Prints a summary of the current run results to file. More...
 
CU_EXPORT char * CU_get_run_results_string (void)
 Creates a string and fills it with a summary of the current run results. More...
 

Variables

static CU_BOOL f_bTestIsRunning = CU_FALSE
 Flag for whether a test run is in progress.
 
static CU_pSuite f_pCurSuite = NULL
 Pointer to the suite currently being run.
 
static CU_pTest f_pCurTest = NULL
 Pointer to the test currently being run.
 
static CU_RunSummary f_run_summary = {"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
 CU_RunSummary to hold results of each test run.
 
static CU_pFailureRecord f_failure_list = NULL
 CU_pFailureRecord to hold head of failure record list of each test run.
 
static CU_pFailureRecord f_last_failure = NULL
 CU_pFailureRecord to hold head of failure record list of each test run.
 
static CU_BOOL f_failure_on_inactive = CU_TRUE
 Flag for whether inactive suites/tests are treated as failures.
 
static clock_t f_start_time
 Variable for storage of start time for test run.
 

Detailed Description

Test run management functions (implementation).