1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <cppunit/extensions/TestFactoryRegistry.h>
24 #include <cppunit/CompilerOutputter.h>
25 #include <cppunit/TestResult.h>
26 #include <cppunit/TestResultCollector.h>
27 #include <cppunit/TestRunner.h>
28 #include <cppunit/TextTestProgressListener.h>
32 main( int argc, char* argv[] )
34 std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
36 // Create the event manager and test controller
37 CppUnit::TestResult controller;
39 // Add a listener that colllects test result
40 CppUnit::TestResultCollector result;
41 controller.addListener( &result );
43 // Add a listener that print dots as test run.
44 CppUnit::TextTestProgressListener progress;
45 controller.addListener( &progress );
47 CppUnit::TestFactoryRegistry& registry =
48 CppUnit::TestFactoryRegistry::getRegistry();
49 // Add the top suite to the test runner
50 CppUnit::TestRunner runner;
51 runner.addTest( registry.makeTest() );
54 std::cout << "Running " << testPath;
55 runner.run( controller, testPath );
57 std::cerr << std::endl;
59 // Print test in a compiler compatible format.
60 CppUnit::CompilerOutputter outputter( &result, std::cerr );
63 catch ( std::invalid_argument &e ) // Test path not resolved
65 std::cerr << std::endl
66 << "ERROR: " << e.what()
71 return result.wasSuccessful() ? 0 : 1;