67 #ifndef CUNIT_TESTRUN_H_SEEN
68 #define CUNIT_TESTRUN_H_SEEN
70 #include "CUnit/CUnit.h"
111 char PackageName[50];
400 CU_EXPORT
int CU_count_suite_tests(
CU_pSuite pSuite);
482 const char *strCondition,
484 const char *strFunction,
503 const char *strCondition,
505 const char *strFunction);
517 #define CU_SKIP_IF(value) \
518 { CU_SkipImplementation((value), __LINE__, ("CU_SKIP_IF(" #value ")"), __FILE__, CU_FUNC); }
522 #ifdef USE_DEPRECATED_CUNIT_NAMES
527 #ifdef CUNIT_BUILD_TESTS
528 void test_cunit_TestRun(
void);
Error handling functions (user interface).
Management functions for tests, suites, and the test registry.
CU_EXPORT unsigned int CU_get_number_of_successes(void)
Retrieves the number of successful assertions during the last run (reset each run).
Definition: TestRun.c:332
CU_EXPORT void CU_set_test_skipped_handler(CU_TestSkippedMessageHandler pTestSkippedMessage)
Sets the message handler to call when a test is skipped.
Definition: TestRun.c:235
CU_EXPORT void CU_print_run_results(FILE *file)
Prints a summary of the current run results to file.
Definition: TestRun.c:656
CU_EXPORT double CU_get_suite_duration(CU_pSuite pSuite)
Definition: TestRun.c:285
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.
Definition: TestRun.c:259
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)...
Definition: TestRun.c:368
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.
Definition: TestRun.c:267
CU_EXPORT int CU_count_test_failures(CU_pTest pTest)
Count the number of failures from the given test.
Definition: TestRun.c:373
CU_pFailureRecord PTestResult
Definition: TestRun.h:524
CU_EXPORT unsigned int CU_get_number_of_failures(void)
Retrieves the number of failed assertions during the last run (reset each run).
Definition: TestRun.c:338
CU_EXPORT void CU_set_suite_complete_handler(CU_SuiteCompleteMessageHandler pSuiteCompleteMessage)
Sets the message handler to call after each suite is run.
Definition: TestRun.c:243
CU_EXPORT void CU_set_test_start_handler(CU_TestStartMessageHandler pTestStartMessage)
Sets the message handler to call before each test is run.
Definition: TestRun.c:219
void(* CU_SuiteStartMessageHandler)(const CU_pSuite pSuite)
Message handler called at the start of a suite.
Definition: TestRun.h:130
CU_EXPORT void CU_set_fail_on_inactive(CU_BOOL new_inactive)
Sets whether an inactive suite or test is treated as a failure.
Definition: TestRun.c:644
CU_EXPORT CU_ErrorCode CU_run_all_tests(void)
Runs all tests in all suites registered in the test registry.
Definition: TestRun.c:472
CU_EXPORT unsigned int CU_get_number_of_asserts(void)
Retrieves the number of assertions processed during the last run (reset each run).
Definition: TestRun.c:326
CU_EXPORT CU_ErrorCode CU_run_suite(CU_pSuite pSuite)
Runs all tests in a specified suite.
Definition: TestRun.c:508
CU_EXPORT CU_SuiteStartMessageHandler CU_get_suite_start_handler(void)
Retrieves the message handler called before each suite is run.
struct CU_RunSummary CU_RunSummary
Data type for holding statistics and assertion failures for a test run.
CU_EXPORT char * CU_get_run_results_string(void)
Creates a string and fills it with a summary of the current run results.
Definition: TestRun.c:672
CU_EXPORT CU_pSuite CU_get_current_suite(void)
Retrieves a pointer to the currently-running suite (NULL if none).
Definition: TestRun.c:626
CU_EXPORT void CU_set_all_test_complete_handler(CU_AllTestsCompleteMessageHandler pAllTestsCompleteMessage)
Sets the message handler to call after all tests have been run.
Definition: TestRun.c:251
enum CU_FailureTypes CU_FailureType
Types of failures occurring during test runs.
CU_EXPORT void CU_set_test_complete_handler(CU_TestCompleteMessageHandler pTestCompleteMessage)
Sets the message handler to call after each test is run.
Definition: TestRun.c:227
CU_EXPORT unsigned int CU_get_number_of_suites_run(void)
Retrieves the number of suites completed during the previous run (reset each run).
Definition: TestRun.c:290
void(* CU_TestSkippedMessageHandler)(const CU_pTest pTest, const CU_pSuite pSuite)
Message handler called when a test is skipped.
Definition: TestRun.h:149
CU_EXPORT void CU_set_suite_start_handler(CU_SuiteStartMessageHandler pSuiteStartMessage)
Sets the message handler to call before each suite is run.
Definition: TestRun.c:211
CU_ErrorCode
CUnit error codes.
Definition: CUError.h:62
CU_EXPORT unsigned int CU_get_number_of_tests_run(void)
Retrieves the number of tests completed during the previous run (reset each run).
Definition: TestRun.c:308
CU_EXPORT double CU_get_elapsed_time(void)
Retrieves the elapsed time for the last run in seconds (reset each run).
Definition: TestRun.c:357
CU_EXPORT CU_ErrorCode CU_run_test(CU_pSuite pSuite, CU_pTest pTest)
Runs a specific test in a specified suite.
Definition: TestRun.c:535
void(* CU_TestStartMessageHandler)(const CU_pTest pTest, const CU_pSuite pSuite)
Message handler called at the start of a test.
Definition: TestRun.h:133
struct CU_FailureRecord CU_FailureRecord
Data type for holding assertion failure information (linked list).
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).
Definition: TestRun.c:314
CU_EXPORT int CU_count_all_failures(CU_pTestRegistry pRegistry)
Count the number of failed tests overall.
Definition: TestRun.c:421
CU_EXPORT CU_TestCompleteMessageHandler CU_get_test_complete_handler(void)
Retrieves the message handler called after each test is run.
void(* CU_SuiteInitFailureMessageHandler)(const CU_pSuite pSuite)
Message handler called when a suite initializer fails.
Definition: TestRun.h:173
CU_EXPORT CU_pTest CU_get_current_test(void)
Retrievea a pointer to the currently-running test (NULL if none).
Definition: TestRun.c:632
CU_EXPORT CU_SuiteInitFailureMessageHandler CU_get_suite_init_failure_handler(void)
Retrieves the message handler called when a suite initialization error occurs.
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).
Definition: TestRun.c:320
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.
Definition: TestRun.c:169
CU_EXPORT CU_SuiteCleanupFailureMessageHandler CU_get_suite_cleanup_failure_handler(void)
Retrieves the message handler called when a suite cleanup error occurs.
CU_EXPORT void CU_set_suite_skipped_handler(CU_SuiteSkippedMessageHandler pSuiteSkipped)
Sets the message handler to call when a suite is skipped.
Definition: TestRun.c:274
CU_EXPORT unsigned int CU_get_number_of_failure_records(void)
Retrieves the number failure records created during the previous run (reset each run).
Definition: TestRun.c:344
CU_EXPORT CU_TestSkippedMessageHandler CU_get_test_skipped_handler(void)
Retrieves the message handler called when a test is skipped.
CU_EXPORT CU_TestStartMessageHandler CU_get_test_start_handler(void)
Retrieves the message handler called before each test is run.
CU_EXPORT int CU_count_suite_failures(CU_pSuite pSuite)
Count the number of failed tests in a suite.
Definition: TestRun.c:395
void(* CU_AllTestsCompleteMessageHandler)(const CU_pFailureRecord pFailure)
Message handler called at the completion of a test run.
Definition: TestRun.h:166
CU_EXPORT CU_AllTestsCompleteMessageHandler CU_get_all_test_complete_handler(void)
Retrieves the message handler called after all tests are 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).
Definition: TestRun.c:302
CU_EXPORT double CU_get_test_duration(CU_pTest pTest)
Definition: TestRun.c:281
CU_EXPORT int CU_count_all_tests(CU_pTestRegistry pRegistry)
Count the number of tests in a suite.
Definition: TestRun.c:408
CU_EXPORT CU_SuiteCompleteMessageHandler CU_get_suite_complete_handler(void)
Retrieves the message handler called after each suite is run.
void(* CU_SuiteSkippedMessageHandler)(const CU_pSuite pSuite)
Message handler called when a suite is skipped during setup.
Definition: TestRun.h:183
void(* CU_TestCompleteMessageHandler)(const CU_pTest pTest, const CU_pSuite pSuite, const CU_pFailureRecord pFailure)
Message handler called at the completion of a test.
Definition: TestRun.h:140
CU_EXPORT CU_BOOL CU_get_fail_on_inactive(void)
Retrieves the current setting for whether inactive suites/tests are treated as failures.
Definition: TestRun.c:650
CU_RunSummary * CU_pRunSummary
Pointer to CU_RunSummary.
Definition: TestRun.h:125
CU_EXPORT void CU_clear_previous_results(void)
Initializes the run summary information stored from the previous test run.
Definition: TestRun.c:620
void(* CU_SuiteCleanupFailureMessageHandler)(const CU_pSuite pSuite)
Message handler called when a suite cleanup function fails.
Definition: TestRun.h:178
CU_FailureTypes
Types of failures occurring during test runs.
Definition: TestRun.h:81
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).
Definition: TestRun.c:296
CU_EXPORT CU_pFailureRecord CU_iterate_test_failures(CU_pTest test, CU_pFailureRecord previous)
Iterate over the recorded failure records of a given test.
Definition: TestRun.c:434
CU_EXPORT CU_BOOL CU_is_test_running(void)
Returns CU_TRUE if a test run is in progress, CU_TRUE otherwise.
Definition: TestRun.c:638
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.
Definition: TestRun.c:139
void(* CU_SuiteCompleteMessageHandler)(const CU_pSuite pSuite, const CU_pFailureRecord pFailure)
Message handler called at the completion of a suite.
Definition: TestRun.h:157
CU_FailureRecord _TestResult
Definition: TestRun.h:523
CU_EXPORT CU_pRunSummary CU_get_run_summary(void)
Count the number of tests in all suites.
Definition: TestRun.c:466
CU_FailureRecord * CU_pFailureRecord
Pointer to CU_FailureRecord.
Definition: TestRun.h:105
@ CUF_SuiteInactive
Inactive suite was run.
Definition: TestRun.h:82
@ CUF_AssertFailed
CUnit assertion failed during test run.
Definition: TestRun.h:86
@ CUF_SuiteInitFailed
Suite initialization function failed.
Definition: TestRun.h:83
@ CUF_SuiteCleanupFailed
Suite cleanup function failed.
Definition: TestRun.h:84
@ CUF_TestInactive
Inactive test was run.
Definition: TestRun.h:85
Data type for holding assertion failure information (linked list).
Definition: TestRun.h:92
unsigned int uiLineNumber
Line number of failure.
Definition: TestRun.h:94
char * strFileName
Name of file where failure occurred.
Definition: TestRun.h:95
struct CU_FailureRecord * pPrev
Pointer to previous record in linked list.
Definition: TestRun.h:102
CU_FailureType type
Failure type.
Definition: TestRun.h:93
char * strCondition
Test condition which failed.
Definition: TestRun.h:97
CU_pSuite pSuite
Suite containing test having failure.
Definition: TestRun.h:99
char * strFunction
Function of failure.
Definition: TestRun.h:96
CU_pTest pTest
Test containing failure.
Definition: TestRun.h:98
struct CU_FailureRecord * pNext
Pointer to next record in linked list.
Definition: TestRun.h:101
Data type for holding statistics and assertion failures for a test run.
Definition: TestRun.h:110
unsigned int nSuitesInactive
Number of suites which were inactive.
Definition: TestRun.h:114
unsigned int nSuitesSkipped
Number of suites skipped during execution.
Definition: TestRun.h:123
unsigned int nTestsRun
Number of tests completed during run.
Definition: TestRun.h:115
unsigned int nFailureRecords
Number of failure records generated.
Definition: TestRun.h:120
unsigned int nTestsFailed
Number of tests containing failed assertions.
Definition: TestRun.h:116
unsigned int nSuitesFailed
Number of suites for which initialization failed.
Definition: TestRun.h:113
unsigned int nAsserts
Number of assertions tested during run.
Definition: TestRun.h:118
double ElapsedTime
Elapsed time for run in seconds.
Definition: TestRun.h:121
unsigned int nAssertsFailed
Number of failed assertions.
Definition: TestRun.h:119
unsigned int nTestsSkipped
Number of tests skipped during execution.
Definition: TestRun.h:122
unsigned int nSuitesRun
Number of suites completed during run.
Definition: TestRun.h:112
unsigned int nTestsInactive
Number of tests which were inactive (in active suites).
Definition: TestRun.h:117
CUnit suite data type.
Definition: TestDB.h:162
CUnit test registry data type.
Definition: TestDB.h:237
CUnit test case data type.
Definition: TestDB.h:110