cppUnitTestRunner.cpp 943 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifdef NICE_USELIB_CPPUNIT
  2. #include <cppunit/CompilerOutputter.h>
  3. #include <cppunit/extensions/TestFactoryRegistry.h>
  4. #include <cppunit/ui/text/TestRunner.h>
  5. #endif
  6. /**
  7. * CppUnit-Testrunner
  8. */
  9. int main(int argc, char* argv[]) {
  10. // shut up warnings
  11. (void)argc;
  12. (void)argv;
  13. #ifdef NICE_USELIB_CPPUNIT
  14. // Get the top level suite from the registry
  15. CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
  16. // Adds the test to the list of test to run
  17. CppUnit::TextUi::TestRunner runner;
  18. runner.addTest( suite );
  19. // Change the default outputter to a compiler error format outputter
  20. runner.setOutputter(
  21. new CppUnit::CompilerOutputter(&runner.result(), std::cerr));
  22. // Run the tests
  23. bool wasSucessful = runner.run();
  24. // Return error code 1 if one of tests failed.
  25. return wasSucessful ? 0 : 1;
  26. #else
  27. #error "Install cppunit (http://cppunit.sourceforge.net/cppunit-wiki)"
  28. return 1;
  29. #endif
  30. }