00001 /* 00002 * CUnit - A Unit testing framework library for C. 00003 * Copyright (C) 2001 Anil Kumar 00004 * Copyright (C) 2004 Anil Kumar, Jerry St.Clair 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 /* 00022 * Contains Interface to Run tests. 00023 * 00024 * Created By : Anil Kumar on ...(in month of Aug 2001) 00025 * Last Modified : 09/Aug/2001 00026 * Comment : Contains generic run tests interface which can be used 00027 * be used for any type of frontend interface framework. 00028 * EMail : aksaharan@yahoo.com 00029 * 00030 * Last Modified : 24/Nov/2001 00031 * Comment : Added Handler for Group Initialization failure condition. 00032 * EMail : aksaharan@yahoo.com 00033 * 00034 * Last Modified : 5-Aug-2004 (JDS) 00035 * Comment : New interface. Since these should be internal functions, 00036 * no support for deprecated version 1 names provided now, 00037 * eliminated global variables for current test & suite, 00038 * moved (renamed) _TestResult here from TestDB.h. 00039 * EMail : jds2@users.sourceforge.net 00040 * 00041 * Modified : 5-Sep-2004 (JDS) 00042 * Comment : Added internal test interface. 00043 * EMail : jds2@users.sourceforge.net 00044 */ 00045 00063 #ifndef _CUNIT_TESTRUN_H 00064 #define _CUNIT_TESTRUN_H 00065 00066 #include "CUnit.h" 00067 #include "CUError.h" 00068 #include "TestDB.h" 00069 00070 #ifdef __cplusplus 00071 extern "C" { 00072 #endif 00073 00074 /* CU_FailureRecord type definition. */ 00076 typedef struct CU_FailureRecord 00077 { 00078 unsigned int uiLineNumber; 00079 char* strFileName; 00080 char* strCondition; 00081 CU_pTest pTest; 00082 CU_pSuite pSuite; 00084 struct CU_FailureRecord* pNext; 00085 struct CU_FailureRecord* pPrev; 00087 } CU_FailureRecord; 00088 typedef CU_FailureRecord* CU_pFailureRecord; 00090 /* CU_RunSummary type definition. */ 00092 typedef struct CU_RunSummary 00093 { 00094 unsigned int nSuitesRun; 00095 unsigned int nSuitesFailed; 00096 unsigned int nTestsRun; 00097 unsigned int nTestsFailed; 00098 unsigned int nAsserts; 00099 unsigned int nAssertsFailed; 00100 unsigned int nFailureRecords; 00101 } CU_RunSummary; 00102 typedef CU_RunSummary* CU_pRunSummary; 00104 /* Type Definitions for Message Handlers. */ 00110 typedef void (*CU_TestStartMessageHandler)(const CU_pTest pTest, const CU_pSuite pSuite); 00119 typedef void (*CU_TestCompleteMessageHandler)(const CU_pTest pTest, const CU_pSuite pSuite, 00120 const CU_pFailureRecord pFailure); 00127 typedef void (*CU_AllTestsCompleteMessageHandler)(const CU_pFailureRecord pFailure); 00132 typedef void (*CU_SuiteInitFailureMessageHandler)(const CU_pSuite pSuite); 00133 00134 /* Get/Set functions for Message Handlers. */ 00135 void CU_set_test_start_handler(CU_TestStartMessageHandler pTestStartMessage); 00136 void CU_set_test_complete_handler(CU_TestCompleteMessageHandler pTestCompleteMessage); 00137 void CU_set_all_test_complete_handler(CU_AllTestsCompleteMessageHandler pAllTestsCompleteMessage); 00138 void CU_set_suite_init_failure_handler(CU_SuiteInitFailureMessageHandler pSuiteInitFailureMessage); 00139 00140 CU_TestStartMessageHandler CU_get_test_start_handler(void); 00141 CU_TestCompleteMessageHandler CU_get_test_complete_handler(void); 00142 CU_AllTestsCompleteMessageHandler CU_get_all_test_complete_handler(void); 00143 CU_SuiteInitFailureMessageHandler CU_get_suite_init_failure_handler(void); 00144 00145 /* Functions for running registered tests and suites. */ 00146 CU_ErrorCode CU_run_all_tests(void); 00147 CU_ErrorCode CU_run_suite(CU_pSuite pSuite); 00148 CU_ErrorCode CU_run_test(CU_pSuite pSuite, CU_pTest pTest); 00149 00150 /* Functions for getting information about the previous test run. */ 00151 unsigned int CU_get_number_of_suites_run(void); 00152 unsigned int CU_get_number_of_suites_failed(void); 00153 unsigned int CU_get_number_of_tests_run(void); 00154 unsigned int CU_get_number_of_tests_failed(void); 00155 unsigned int CU_get_number_of_asserts(void); 00156 unsigned int CU_get_number_of_successes(void); 00157 unsigned int CU_get_number_of_failures(void); 00158 unsigned int CU_get_number_of_failure_records(void); 00159 CU_pFailureRecord CU_get_failure_list(void); 00160 CU_pRunSummary CU_get_run_summary(void); 00161 00162 /* Functions for internal & testing use. */ 00163 CU_pSuite CU_get_current_suite(void); 00164 CU_pTest CU_get_current_test(void); 00165 BOOL CU_is_test_running(void); 00166 void CU_clear_previous_results(void); 00167 00168 /* Assertion implementation function. */ 00169 BOOL CU_assertImplementation(BOOL bValue, 00170 unsigned int uiLine, 00171 char strCondition[], 00172 char strFile[], 00173 char strFunction[], 00174 BOOL bFatal); 00175 00176 #ifdef USE_DEPRECATED_CUNIT_NAMES 00177 typedef CU_FailureRecord _TestResult; 00178 typedef CU_pFailureRecord PTestResult; 00179 #endif /* USE_DEPRECATED_CUNIT_NAMES */ 00180 00181 #ifdef CUNIT_BUILD_TESTS 00182 void test_cunit_TestRun(void); 00183 #endif 00184 00185 #ifdef __cplusplus 00186 } 00187 #endif 00188 00189 #endif /* _CUNIT_TESTRUN_H */ 00190