OSDN Git Service

953d0baaadf7af06fd97604cd05dccc396f22675
[ccunit/ccunit.git] / src / ccunit / CCUnitTestRunner.h
1 /* -*- mode: 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 #ifndef CCUNITTESTRUNNER_H
25 #define CCUNITTESTRUNNER_H
26
27 #include <stdio.h>
28 #include <ccunit/CCUnitConfig.h>
29 #include <ccunit/CCUnitTestResult.h>
30 #include <ccunit/CCUnitTestSuite.h>
31 #include <ccunit/CCUnitTestListener.h>
32
33 typedef struct CCUnitTestRunner CCUnitTestRunner;
34 typedef int (*ccunit_runsuite_func_t)(CCUnitTestRunner*, CCUnitTestSuite*);
35
36 /**
37  * A command line based tool to run tests.  Runs a single test and
38  * collects its results.  This method can be used to start a test run
39  * from your program.
40  * <pre>
41  *     int main (int ac, char** av)
42  *     {
43  *         CCUnitTestRunner* runner = ccunit_newTestRunner (NULL);
44  *         CCUnitTestSuite* suite = CREATE_TESTSUITE ();
45  *         return runner->run (runner, suite);
46  *     }
47  * </pre>
48  * @see CCUnitTestSuite
49  * @see CCUnitTestCase
50  */
51 struct CCUnitTestRunner
52 {
53   CCUnitTestListener listener;                  /**< test listeners */
54   CCUnitTestResult* result;                     /**< test result container */
55   ccunit_runsuite_func_t run;                   /**< test run function */
56   FILE* ofp;                                    /**< result output stream */
57 };
58
59 /**
60  * constructor.
61  * @param output prints test result into this stream.
62  * @return new CCUnitTestRunner object.
63  */
64 extern CCUnitTestRunner* ccunit_newTestRunner (FILE* output);
65
66 /**
67  * destructor.
68  * @param runner TestRunner object to destruct.
69  */
70 extern void ccunit_deleteTestRunner (CCUnitTestRunner* runner);
71
72 #endif