1 // Copyright (C) 2019-2021 EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include <cppunit/CompilerOutputter.h>
20 #include <cppunit/TestResult.h>
21 #include <cppunit/TestResultCollector.h>
22 #include <cppunit/TextTestProgressListener.h>
23 #include <cppunit/BriefTestProgressListener.h>
24 #include <cppunit/extensions/TestFactoryRegistry.h>
25 #include <cppunit/TestRunner.h>
26 #include <cppunit/TextTestRunner.h>
33 // ============================================================================
35 * Main program source for Unit Tests with cppunit package does not depend
36 * on actual tests, so we use the same for all partial unit tests.
38 // ============================================================================
40 int main(int argc, char* argv[])
42 // --- Create the event manager and test controller
43 CPPUNIT_NS::TestResult controller;
45 // --- Add a listener that collects test result
46 CPPUNIT_NS::TestResultCollector result;
47 controller.addListener( &result );
49 // --- Add a listener that print dots as test run.
51 CPPUNIT_NS::TextTestProgressListener progress;
53 CPPUNIT_NS::BriefTestProgressListener progress;
55 controller.addListener( &progress );
57 // --- Get the top level suite from the registry
59 CPPUNIT_NS::Test *suite =
60 CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
62 // --- Adds the test to the list of test to run
64 CPPUNIT_NS::TestRunner runner;
65 runner.addTest( suite );
66 runner.run( controller);
68 // --- Print test in a compiler compatible format.
69 std::ofstream testFile;
70 testFile.open("test.log", std::ios::out | std::ios::app);
71 testFile << "------ Idefix test log:" << std::endl;
72 CPPUNIT_NS::CompilerOutputter outputter( &result, testFile );
77 bool wasSucessful = result.wasSuccessful();
80 // --- Return error code 1 if the one of test failed.
82 return wasSucessful ? 0 : 1;