1 /*
2  *  CUnit - A Unit testing framework library for C.
3  *  Copyright (C) 2004-2006  Jerry St.Clair
4  *
5  *  This library is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU Library General Public
7  *  License as published by the Free Software Foundation; either
8  *  version 2 of the License, or (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *  Library General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Library General Public
16  *  License along with this library; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 
20 /*
21  *  Interface for simple test runner.
22  *
23  *  11-Aug-2004   Initial implementation of basic test runner interface. (JDS)
24  */
25 
26 /** @file
27  * Basic interface with output to stdout.
28  */
29 /** @addtogroup Basic
30  * @{
31  */
32 
33 #ifndef CUNIT_BASIC_H_SEEN
34 #define CUNIT_BASIC_H_SEEN
35 
36 #include "CUnit.h"
37 #include "TestDB.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /** Run modes for the basic interface. */
44 typedef enum {
45   CU_BRM_NORMAL = 0,  /**< Normal mode - failures and run summary are printed [default]. */
46   CU_BRM_SILENT,      /**< Silent mode - no output is printed except framework error messages. */
47   CU_BRM_VERBOSE      /**< Verbose mode - maximum output of run details. */
48 } CU_BasicRunMode;
49 
50 CU_EXPORT CU_ErrorCode CU_basic_run_tests(void);
51 /**<
52  *  Runs all registered CUnit tests using the basic interface.
53  *  The default CU_BasicRunMode is used unless it has been
54  *  previously changed using CU_basic_set_mode().  The CUnit test
55  *  registry must have been initialized before calling this function.
56  *
57  *  @return A CU_ErrorCode indicating the framework error condition, including
58  *          CUE_NOREGISTRY - Registry has not been initialized.
59  */
60 
61 CU_EXPORT CU_ErrorCode CU_basic_run_suite(CU_pSuite pSuite);
62 /**<
63  *  Runs all tests for a specific suite in the basic interface.
64  *  If pSuite is NULL, the function returns without taking any
65  *  action. The default CU_BasicRunMode is used unless it has
66  *  been changed using CU_basic_set_mode().
67  *
68  *  @param pSuite The CU_Suite to run.
69  *  @return A CU_ErrorCode indicating the framework error condition, including
70  *          CUE_NOSUITE - pSuite was NULL.
71  */
72 
73 CU_EXPORT CU_ErrorCode CU_basic_run_test(CU_pSuite pSuite, CU_pTest pTest);
74 /**<
75  *  Runs a single test in a specific suite in the basic interface.
76  *  If pSuite or pTest is NULL, the function returns without
77  *  taking any action.  The default CU_BasicRunMode is used unless
78  *  it has been changed using CU_basic_set_mode.
79  *
80  *  @param pSuite The CU_Suite holding the CU_Test to run.
81  *  @param pTest  The CU_Test to run.
82  *  @return A CU_ErrorCode indicating the framework error condition, including
83  *          CUE_NOSUITE - pSuite was NULL.
84  *          CUE_NOTEST  - pTest was NULL.
85  */
86 
87 CU_EXPORT void CU_basic_set_mode(CU_BasicRunMode mode);
88 /**< Sets the run mode for the basic interface.
89  *  @param mode The new CU_BasicRunMode for subsequent test
90  *              runs using the basic interface.
91  */
92 
93 CU_EXPORT CU_BasicRunMode CU_basic_get_mode(void);
94 /**< Retrieves the current run mode for the basic interface.
95  *  @return The current CU_BasicRunMode setting for test
96  *              runs using the basic interface.
97  */
98 
99 CU_EXPORT void CU_basic_show_failures(CU_pFailureRecord pFailure);
100 /**<
101  *  Prints a summary of run failures to stdout.
102  *  This is provided for user convenience upon request, and does
103  *  not take into account the current run mode.  The failures are
104  *  printed to stdout independent of the most recent run mode.
105  *
106  *  @param pFailure List of CU_pFailureRecord's to output.
107  */
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 #endif  /*  CUNIT_BASIC_H_SEEN  */
113 /** @} */
114