1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _BASICMAINTEST_HXX_
21 #define _BASICMAINTEST_HXX_
23 #include <cppunit/CompilerOutputter.h>
24 #include <cppunit/TestResult.h>
25 #include <cppunit/TestResultCollector.h>
26 #include <cppunit/TextTestProgressListener.h>
27 #include <cppunit/BriefTestProgressListener.h>
28 #include <cppunit/extensions/TestFactoryRegistry.h>
29 #include <cppunit/TestRunner.h>
30 #include <cppunit/TextTestRunner.h>
37 // ============================================================================
39 * Main program source for Unit Tests with cppunit package does not depend
40 * on actual tests, so we use the same for all partial unit tests.
42 // ============================================================================
44 #include "UnitTestsResult.hxx"
46 int main(int argc, char* argv[])
48 // --- Create the event manager and test controller
49 CPPUNIT_NS::TestResult controller;
51 // --- Add a listener that collects test result
52 CPPUNIT_NS::TestResultCollector result;
53 controller.addListener( &result );
55 // --- Add a listener that print dots as test run.
57 CPPUNIT_NS::TextTestProgressListener progress;
59 CPPUNIT_NS::BriefTestProgressListener progress;
61 controller.addListener( &progress );
63 // --- Get the top level suite from the registry
65 CPPUNIT_NS::Test *suite =
66 CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
68 // --- Adds the test to the list of test to run
70 CPPUNIT_NS::TestRunner runner;
71 //CPPUNIT_NS::TextTestRunner runner;
72 runner.addTest( suite );
73 runner.run( controller);
74 //bool wasSucessful = runner.run();
76 // --- Print test in a compiler compatible format.
78 system("mkdir -p /tmp/${USER}");
79 std::ofstream testFile;
80 testFile.open(UnitTestsResult.c_str(), std::ios::out | std::ios::app);
81 testFile << UNIT_TEST_HEADER << endl;
82 //CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
83 CPPUNIT_NS::CompilerOutputter outputter( &result, testFile );
88 bool wasSucessful = result.wasSuccessful();
91 // --- Return error code 1 if the one of test failed.
93 return wasSucessful ? 0 : 1;