1 #include <cppunit/extensions/TestFactoryRegistry.h>
2 #include <cppunit/CompilerOutputter.h>
3 #include <cppunit/TestResult.h>
4 #include <cppunit/TestResultCollector.h>
5 #include <cppunit/TestRunner.h>
6 #include <cppunit/TextTestProgressListener.h>
8 #include <QApplication>
10 int main( int argc, char* argv[] )
12 QApplication anApp( argc, argv );
14 std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
16 // Create the event manager and test controller
17 CppUnit::TestResult controller;
19 // Add a listener that colllects test result
20 CppUnit::TestResultCollector result;
21 controller.addListener( &result );
23 // Add a listener that print dots as test run.
24 CppUnit::TextTestProgressListener progress;
25 controller.addListener( &progress );
27 CppUnit::TestFactoryRegistry& registry =
28 CppUnit::TestFactoryRegistry::getRegistry();
29 // Add the top suite to the test runner
30 CppUnit::TestRunner runner;
31 runner.addTest( registry.makeTest() );
34 std::cout << "Running " << testPath;
35 runner.run( controller, testPath );
37 std::cerr << std::endl;
39 // Print test in a compiler compatible format.
40 CppUnit::CompilerOutputter outputter( &result, std::cerr );
43 catch ( std::invalid_argument &e ) // Test path not resolved
45 std::cerr << std::endl
46 << "ERROR: " << e.what()
51 return result.wasSuccessful() ? 0 : 1;