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>
11 main( int argc, char* argv[] )
13 // to perform "drawing" qt tests
14 QApplication app(argc, argv);
16 std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
18 // Create the event manager and test controller
19 CppUnit::TestResult controller;
21 // Add a listener that colllects test result
22 CppUnit::TestResultCollector result;
23 controller.addListener( &result );
25 // Add a listener that print dots as test run.
26 CppUnit::TextTestProgressListener progress;
27 controller.addListener( &progress );
29 CppUnit::TestFactoryRegistry& registry =
30 CppUnit::TestFactoryRegistry::getRegistry();
31 // Add the top suite to the test runner
32 CppUnit::TestRunner runner;
33 runner.addTest( registry.makeTest() );
36 std::cout << "Running " << testPath;
37 runner.run( controller, testPath );
39 std::cerr << std::endl;
41 // Print test in a compiler compatible format.
42 CppUnit::CompilerOutputter outputter( &result, std::cerr );
45 catch ( std::invalid_argument &e ) // Test path not resolved
47 std::cerr << std::endl
48 << "ERROR: " << e.what()
53 return result.wasSuccessful() ? 0 : 1;