2 EasyUnit : Simple C++ Unit testing framework
3 Copyright (C) 2004 Barthelemy Dagenais
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser 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
20 barthelemy@prologique.com
23 #ifndef TESTREGISTRY_H
24 #define TESTREGISTRY_H
28 #include "testprinter.h"
29 #include "simplestring.h"
30 #include "testrunner.h"
31 #include "testresult.h"
35 * The TestRegistry is the main class used to register all tests,
36 * and create appropriate TestCase. It can then be used to run
37 * tests and print results. All methods that should be used by
38 * the user are static.
47 * Add a test in the registry. If the previous TestCase was not the same
48 * as the one of the current test, a new TestCase is created.
50 * @param test Test to be added
52 static void addTest (Test
*test
);
55 * Run all tests in the registry (default test runner) and return
58 * @return The test results
60 static const TestResult
* run();
63 * Pass all tests in the registry to the TestRunner runner and
64 * return the results of all tests ran.
66 * @param runner The custom runner used to decided which test to run
67 * @return The test results of all tests ran
69 static const TestResult
* run(TestRunner
*runner
);
72 * Run all tests in the registry (default test runner) and return
73 * the test results. This will also print the results using the
74 * default test printer (normal level of details and to the standard
77 * @return The test results
79 static const TestResult
* runAndPrint();
82 * Pass all tests in the registry to the TestRunner runner and
83 * return the results of all tests ran. This will also print the results
84 * using the default test printer (normal level of details and to the
87 * @param runner The custom runner used to decided which test to run
88 * @return The test results
90 static const TestResult
* runAndPrint(TestRunner
*runner
);
93 * Run all tests in the registry (default test runner) and return
94 * the test results. Results will also be given to
95 * to the TestPrinter printer.
97 * @param printer The custom printer used to print the test results
98 * @return The test results
100 static const TestResult
* runAndPrint(TestPrinter
*printer
);
103 * Pass all tests in the registry to the TestRunner runner and
104 * return the results of all tests ran. Results will also be given to
105 * to the TestPrinter printer.
107 * @param printer The custom printer used to print the test results
108 * @param runner The custom runner used to decided which test to run
109 * @return The test results
111 static const TestResult
* runAndPrint(TestPrinter
*printer
, TestRunner
*runner
);
114 static TestRegistry
& instance();
116 void add(Test
*test
);
117 void addTestCase(TestCase
*testCase
);
118 const TestResult
* runTests(TestRunner
*runner
);
119 TestCase
*currentTC_
;
120 TestPrinter
*defaultPrinter_
;
122 TestRunner
*defaultRunner_
;
123 TestResult testResult_
;
126 #endif // TESTREGISTRY_H