OSDN Git Service

add test suite definition struct
[ccunit/ccunit.git] / src / ccunit / CCUnitTestSuite.h
1 /* -*- C -*- */
2 /* Copyright (C) 2003 TSUTSUMI Kikuo.
3    This file is part of the CCUnit Library.
4
5    The CCUnit Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public License
7    as published by the Free Software Foundation; either version 2.1 of
8    the License, or (at your option) any later version.
9
10    The CCUnit Library is distributed in the hope that it will be
11    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the CCUnit Library; see the file COPYING.LESSER.
17    If not, write to the Free Software Foundation, Inc., 59 Temple
18    Place - Suite 330, Boston, MA 02111-1307, USA.  
19 */
20
21 /*
22  * $Id$
23  */
24 /** @file
25  * TestSuite module.
26  */
27 #ifndef CCUNITTESTSUITE_H
28 #define CCUNITTESTSUITE_H
29
30 #include <ccunit/CCUnitConfig.h>
31 #include <ccunit/CCUnitList.h>
32 #include <ccunit/CCUnitTest.h>
33 #include <ccunit/CCUnitTestFixture.h>
34 #include <ccunit/CCUnitTestResult.h>
35
36 /**
37  * @ingroup CCUnitTest
38  * @defgroup CCUnitTestSuite TestSuite
39  *
40  * A <code>Composite</code> class of Tests.
41  * It runs a collection of test cases.
42  * @{
43  */
44
45 /**
46  * A <code>Composite</code> class of Tests.
47  * It runs a collection of test cases. Here is an example.
48  *
49  * @code
50  * CCUnitTestSuite* suite = ccunit_newTestSuite ();
51  * ccunit_addTestCase (suite, TESTCASE_1);
52  * ccunit_addTestCase (suite, TESTCASE_2);
53  * @endcode
54  *
55  * @see CCUnitTest, CCUnitTestCase.
56  * @ingroup CreatingTestSuite
57  */
58 typedef struct CCUnitTestSuite
59 {
60   CCUnitTest test;                  /**< super class */
61   const char* name;                 /**< test suite name */
62   CCUnitList tests;                 /**< added test case/suite list */
63 } CCUnitTestSuite;
64
65 typedef struct CCUnitTestSuiteDfn
66 {
67   CCUnitTestDfn test;               /**< super class */
68   const char* name;                 /**< test suite name */
69   CCUnitTestDfn* tests[];           /**< added test case/suite list */
70 } CCUnitTestSuiteDfn;
71
72 /**
73  * Constructs an empty TestSuite.
74  * @param name test suite name.
75  * @return new test suite.
76  * @ingroup CreatingTestSuite
77  */
78 extern inline CCUnitTestSuite* ccunit_newTestSuite(const char* name);
79
80 /**
81  * Constructs a TestSuite from definition struct.
82  * @param sdp test suite definition.
83  * @return new test suite.
84  */
85 extern CCUnitTestSuite* ccunit_newTestSuiteFromDfn (const CCUnitTestSuiteDfn* sdp);
86
87 /**
88  * Destructs test suite.
89  * @param suite deleting suite.
90  * @ingroup CreatingTestSuite
91  */
92 extern inline void ccunit_deleteTestSuite (CCUnitTestSuite* suite);
93
94 /**
95  * Adds a test to the suite.
96  * @param suite test suite.
97  * @param test test to add.
98  * @ingroup CreatingTestSuite
99  */
100 extern inline void ccunit_addTest (CCUnitTestSuite* suite, CCUnitTest* test);
101
102 /**
103  * Adds a test suite to the suite.
104  * @param suite test suite.
105  * @param testSuite test to add.
106  * @ingroup CreatingTestSuite
107  */
108 extern inline void ccunit_addTestSuite (CCUnitTestSuite* suite,
109                                         CCUnitTestSuite* testSuite);
110
111 /**
112  * Adds a test fixture to the suite.
113  * @param suite test suite.
114  * @param fixture test to add.
115  * @ingroup CreatingTestSuite
116  */
117 extern inline void ccunit_addTestFixture (CCUnitTestSuite* suite,
118                                           CCUnitTestFixture* fixture);
119
120 /**
121  * run test suite and collect its results.
122  * @param suite test suite.
123  * @param result test result. if NULL, create a new result object and return it.
124  * @return test result.
125  * @ingroup ExecutingTest
126  */
127 extern inline CCUnitTestResult* ccunit_runTestSuite (CCUnitTestSuite* suite,
128                                                      CCUnitTestResult* result);
129
130 /**
131  * Create a test suite from test source file.
132  * @param name test suite name.
133  * @return new test suite.
134  * @ingroup CreatingTestSuite
135  */
136 extern CCUnitTestSuite* ccunit_suite (const char* name);
137
138 /** @} */
139 #endif