int main(/*int argc, char ** argv*/) { // UnitTest CppUnit::TextTestRunner runner; runner.setOutputter(CppUnit::CompilerOutputter::defaultOutputter(&runner.result(), std::cerr)); CppUnit::BriefTestProgressListener progress; runner.eventManager().addListener( &progress ); CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest( registry.makeTest() ); runner.run(); return 0; }
int main (int argc, char *argv[]) { // Start MPI if this is a parallel build. #if RUNMPI == true MPI_Init(&argc, &argv); #endif // Print a header message. #if RUNMPI == true if (MPICommons::isMaster()) { CppUnit::stdCOut() << std::endl << "Running KMCLib C++ unit tests on " << MPICommons::size() << " MPI processes." << std::endl; } #else CppUnit::stdCOut() << std::endl << "Running KMCLib C++ unit tests." << std::endl; #endif // Setup the tests. CppUnit::Test *test = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); CppUnit::TextTestRunner runner; runner.addTest(test); // Add our custom outputter. runner.setOutputter( new CustomOutputter(&runner.result(), std::cout) ); // Add our custom progress listener. CppUnit::TestResult & event_manager = runner.eventManager(); CustomProgressListener progress; event_manager.addListener( &progress ); // Run the tests. runner.run(std::string(""), false, true, false); // Remove the progress listener. event_manager.removeListener( &progress ); // Finalize if MPI. #if RUNMPI == true MPI_Finalize(); #endif // DONE return 0; }
int main(int argc,char **argv) { //setup the test runner CppUnit::TextTestRunner runner; CppUnit::TextTestProgressListener progress; CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest(registry.makeTest()); runner.eventManager().addListener(&progress); std::ofstream os("unittest.xml"); runner.setOutputter(new CppUnit::XmlOutputter(&runner.result(),os)); bool result = runner.run(); return result ? 0 : 1; }
int main(int argc, char ** argv) { #if defined(_WIN32) && !defined(__CYGWIN__) Agelena::Loggers::DefaultWindowsLogger logger; #else Agelena::Loggers::DefaultPOSIXLogger logger; #endif // UnitTest CppUnit::TextTestRunner runner; runner.setOutputter(CppUnit::CompilerOutputter::defaultOutputter(&runner.result(), std::cerr)); CppUnit::BriefTestProgressListener progress; runner.eventManager().addListener( &progress ); CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest( registry.makeTest() ); runner.run(); return 0; }
int MWorksCoreTestMain(int argc, char *argv[]) { if (argc < 2) { std::cerr << "Usage: " << argv[0] << " results_file [test_name ...]" << std::endl; return 2; } if (NULL != getenv("MWORKS_PAUSE_FOR_DEBUGGER")) { std::cerr << "Waiting for debugger to attach..."; pause(); std::cerr << " continuing" << std::endl; } CppUnit::TextTestRunner runner; std::ofstream outfile( argv[1] ); CppUnit::XmlOutputter *outputter = new CppUnit::XmlOutputter(&runner.result(), outfile); runner.setOutputter(outputter); MWorksTestProgressListener listener; runner.eventManager().addListener( &listener ); CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry("Unit Test"); runner.addTest( registry.makeTest() ); bool returnval = true; if (argc > 2) { // Run specified tests for (int i = 2; i < argc; i++) { returnval = runner.run( argv[i], false, false, false ) && returnval; } } else { // Run all tests returnval = runner.run( "", false, false, false ); } outputter->write(); outfile.close(); // return !returnval because it is 1 on success return !returnval; }
int main(int argc, char ** argv) { #if defined(_WIN32) && !defined(__CYGWIN__) Agelena::Loggers::DefaultWindowsLogger logger; #else Agelena::Loggers::DefaultPOSIXLogger logger; #endif if (argc > 1) cert_path__ = boost::filesystem::path(argv[1], boost::filesystem::native); else std::cerr << "No path to the SSL certificate for the tests was specified - test won't be performed" << std::endl;; // UnitTest CppUnit::TextTestRunner runner; runner.setOutputter(CppUnit::CompilerOutputter::defaultOutputter(&runner.result(), std::cerr)); CppUnit::BriefTestProgressListener progress; runner.eventManager().addListener( &progress ); CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest( registry.makeTest() ); runner.run(); return 0; }
// Run // int TestApp::RunTests() { #if wxUSE_LOG // Switch off logging unless --verbose bool verbose = wxLog::GetVerbose(); wxLog::EnableLogging(verbose); #else bool verbose = false; #endif CppUnit::TextTestRunner runner; if ( m_registries.empty() ) { // run or list all tests which use the CPPUNIT_TEST_SUITE_REGISTRATION() macro // (i.e. those registered in the "All tests" registry); if there are other // tests not registered with the CPPUNIT_TEST_SUITE_REGISTRATION() macro // then they won't be listed/run! AddTest(runner, TestFactoryRegistry::getRegistry().makeTest()); if (m_list) { cout << "\nNote that the list above is not complete as it doesn't include the \n"; cout << "tests disabled by default.\n"; } } else // run only the selected tests { for (size_t i = 0; i < m_registries.size(); i++) { const wxString reg = m_registries[i]; Test *test = GetTestByName(reg); if ( !test && !reg.EndsWith("TestCase") ) { test = GetTestByName(reg + "TestCase"); } if ( !test ) { cerr << "No such test suite: " << string(reg.mb_str()) << endl; return 2; } AddTest(runner, test); } } if ( m_list ) return EXIT_SUCCESS; runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), cout)); // there is a bug // (http://sf.net/tracker/index.php?func=detail&aid=1649369&group_id=11795&atid=111795) // in some versions of cppunit: they write progress dots to cout (and not // cerr) and don't flush it so all the dots appear at once at the end which // is not very useful so unbuffer cout to work around this cout.setf(ios::unitbuf); // add detail listener if needed DetailListener detailListener(m_timing); if ( m_detail || m_timing ) runner.eventManager().addListener(&detailListener); // finally ensure that we report our own exceptions nicely instead of // giving "uncaught exception of unknown type" messages runner.eventManager().pushProtector(new wxUnitTestProtector); bool printProgress = !(verbose || m_detail || m_timing); runner.run("", false, true, printProgress); return runner.result().testFailures() == 0 ? EXIT_SUCCESS : EXIT_FAILURE; }
int main(int testargc, char** testargv) { int rc = 0; #ifdef HAVE_LIBCPPUNIT static const KCmdLineOptions options[] = { { "+[test_suite]", ("Optionally specify a test suite"), 0 }, { "", ("Optional arguments are for ctest"), 0 }, KCmdLineLastOption // End of options. }; // we seem to need a KApplication object to use KGlobal::locale() KCmdLineArgs::init(testargc, testargv, testargv[0], "UNIT TESTS", "", "0.1"); KCmdLineArgs::addCmdLineOptions( options ); KApplication::disableAutoDcopRegistration(); KApplication app(false, false); #ifdef _CHECK_MEMORY _CheckMemory_Init(0); #endif // mymoney tests //CPPUNIT_TEST_SUITE_REGISTRATION(KReportsViewTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyMapTest); CPPUNIT_TEST_SUITE_REGISTRATION(ConverterTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyKeyValueContainerTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneySplitTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyMoneyTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyAccountTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyScheduleTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyDatabaseMgrTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneySeqAccessMgrTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyFileTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyObjectTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyInstitutionTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyFinancialCalculatorTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyTransactionTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneySecurityTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyForecastTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyExceptionTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyObserverTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyPriceTest); CPPUNIT_TEST_SUITE_REGISTRATION(MyMoneyPayeeTest); CPPUNIT_TEST_SUITE_REGISTRATION(PivotGridTest); CPPUNIT_TEST_SUITE_REGISTRATION(PivotTableTest); CPPUNIT_TEST_SUITE_REGISTRATION(QueryTableTest); // off we go CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); // run all tests if no test is specified on the command line // this way, CTest can perform each test individually CppUnit::Test *suite = registry.makeTest(); if (testargc>1) { try { suite = suite->findTest(testargv[1]); } catch(const std::invalid_argument &ex) { // oh, cmake perfomed bad at guessing the correct test names. std::cout << ex.what() << std::endl; // we output that the test passed since the test is deactivated return 0; } } CppUnit::TextTestRunner* runner = new CppUnit::TextTestRunner(); runner->addTest(suite); MyProgressListener progress; CppUnit::TestResultCollector result; runner->eventManager().addListener(&progress); runner->eventManager().addListener(&result); runner->run(); std::cout << "Tests were run with CPPUNIT version " CPPUNIT_VERSION << std::endl; rc = result.wasSuccessful() ? 0 : 1; delete runner; // make sure to delete the singletons before we start memory checking // to avoid false error reports // delete MyMoneyFile::instance(); #ifdef _CHECK_MEMORY chkmem.CheckMemoryLeak( true ); _CheckMemory_End(); #endif // _CHECK_MEMORY #else std::cout << "libcppunit not installed. no automatic tests available." << std::endl; #endif // HAVE_LIBCPPUNIT return rc; }