// Execute and run unit test int main(int argc, char** argv) { CppUnit::TextUi::TestRunner runnerStdcerr; runnerStdcerr.addTest(testMatchRegEx::suite()); runnerStdcerr.setOutputter(new CppUnit::CompilerOutputter( &runnerStdcerr.result(), cerr )); runnerStdcerr.run(); return runnerStdcerr.result().testFailuresTotal(); }
int main(int argc, char **argv) { if (argc != 2) { cerr << "ERROR: Path to unit test folder is not given!" << endl; cerr << "Exit the unit test!" << endl; exit(EXIT_FAILURE); } else { pathToFolderOfFiles = argv[1]; pathToFolderOfFiles.append("/files/"); } std::ofstream file("unitTestResult.xml"); EMPIRE::Message::userSetOutputLevel = EMPIRE::Message::DEBUG; // may output some data for checking // 1. add registered tests to testRunner CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); CppUnit::TextUi::TestRunner runner; runner.addTest(registry.makeTest()); // 2. set listener which outputs the progress to shell EMPIRE::ProgressOutputter testProgressOutputter; runner.eventManager().addListener(&testProgressOutputter); // 3. run runner.run(); // 4. output to xml file CppUnit::XmlOutputter xmlOutputter(&runner.result(), file); xmlOutputter.write(); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { bool wasSuccessful = false; try { CppUnit::TextUi::TestRunner runner; runner.setOutputter( new CppUnit::CompilerOutputter(&runner.result(), std::cerr)); /*CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry("BlackLagoonTestSuite"); runner.addTest(registry.makeTest()); wasSuccessful = runner.run("", false);*/ CppUnit::TestFactoryRegistry ®istry1 = CppUnit::TestFactoryRegistry::getRegistry("HighScoreComponentTestSuite"); CppUnit::TestFactoryRegistry ®istry2 = CppUnit::TestFactoryRegistry::getRegistry("PlayerTestSuite"); CppUnit::TestFactoryRegistry ®istry3 = CppUnit::TestFactoryRegistry::getRegistry("GameObjectTestSuite"); runner.addTest(registry1.makeTest()); runner.addTest(registry2.makeTest()); runner.addTest(registry3.makeTest()); wasSuccessful = runner.run("", false); } catch(const std::exception& e) { std::cerr << e.what() << std::endl; wasSuccessful = false; } return (wasSuccessful == true) ? 0 : 1; }
int main( int /*argc*/, char** /*argv*/) { /// Get the top level suite from the registry CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); /// Adds the test to the list of test to run CppUnit::TextUi::TestRunner runner; runner.addTest( suite ); // Change the default outputter to a compiler error format outputter // uncomment the following line if you need a compiler outputter. runner.setOutputter(new CppUnit::CompilerOutputter( &runner.result(), std::cout ) ); // Change the default outputter to a xml error format outputter // uncomment the following line if you need a xml outputter. //runner.setOutputter( new CppUnit::XmlOutputter( &runner.result(), // std::cerr ) ); /// Run the tests. // bool wasSuccessful = runner.run(); // If you want to avoid the CppUnit typical output change the line above // by the following one: bool wasSuccessful = runner.run("",false,true,false); // Return error code 1 if the one of test failed. // Uncomment the next line if you want to integrate CppUnit with Oval if(!wasSuccessful) std::cerr <<"Error: CppUnit Failures"<<std::endl; std::cout <<"[OVAL] Cppunit-result ="<<!wasSuccessful<<std::endl; return wasSuccessful ? 0 : 1; }
int main( int argc, char* argv[] ) { ProjetUnivers::Kernel::Parameters::load("sound.config") ; ProjetUnivers::Kernel::Log::init() ; // if command line contains "-selftest" then this is the post build check // => the output must be in the compiler error format. bool selfTest = (argc > 1) && (std::string("-selftest") == argv[1]); CppUnit::TextUi::TestRunner runner; CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest( registry.makeTest() ); if ( selfTest ) { // Change the default outputter to a compiler error format outputter // The test runner owns the new outputter. runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter( &runner.result(), std::cerr ) ); } // Run the test. bool wasSucessful = runner.run( "" ); ProjetUnivers::Kernel::Log::close() ; // Return error code 1 if the one of test failed. return wasSucessful ? 0 : 1; }
int main( int argc, char ** argv ) { CppUnit::TextUi::TestRunner runner; CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest( registry.makeTest() ); ofstream out; if ( argc == 2 ) { out.open( argv[ 1 ] ); } runner.setOutputter( new CppUnit::XmlOutputter( &runner.result(), ( out.is_open() ? out : std::cerr ) ) ); // Run the tests. bool wasSucessful = runner.run(); if ( out.is_open() ) { out.close(); } // Return error code 1 if the one of test failed. return wasSucessful ? 0 : 1; }
int main(int argc, const char* argv[]){ CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); CppUnit::TextUi::TestRunner runner; #ifdef DATA_FILENAME const char* path = TOP_SRCDIR "/" DATA_FILENAME; FILE* fp = fopen(path, "r"); if ( !fp ){ fprintf(stderr, "failed to read `%s'\n", path); return 1; } /* read the test packet */ int bytes; const int expected = DATA_SIZE; if ( (bytes=fread(data, 1, sizeof(data), fp)) < expected ){ fprintf(stderr, "failed to read `%s' (data truncated, read %d bytes, expected %d)\n", path, bytes, expected); return 1; } fclose(fp); #endif runner.addTest(suite); runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr)); return runner.run() ? 0 : 1; }
int main( int argc, char* argv[] ) { ProjetUnivers::Kernel::Parameters::load("physic.config") ; ProjetUnivers::Kernel::Log::init() ; // if command line contains "-selftest" then this is the post build check // => the output must be in the compiler error format. bool selfTest = (argc > 1) && (std::string("-selftest") == argv[1]); CppUnit::TextUi::TestRunner runner; CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest( registry.makeTest() ); // Define the file that will store the XML output. std::ofstream outputFile("tests_physic.xml"); CppUnit::MultiOutputter* outputter = new CppUnit::MultiOutputter() ; outputter->add(new CppUnit::CompilerOutputter(&runner.result(),std::cerr)) ; outputter->add(new ProjetUnivers::Kernel::XmlOutputter(&runner,outputFile)) ; runner.setOutputter(outputter); // Run the test. bool wasSucessful = runner.run( "" ); ProjetUnivers::Kernel::Log::close() ; // Return error code 1 if the one of test failed. return wasSucessful ? 0 : 1; }
//////////////////////////////////////////////////////////////////////// /// /// @fn bool BancTests::executer() /// /// Cette fonction exécute l'ensemble des tests unitaires définis. /// La sortie de l'exécution des tests se fait dans la console standard /// d'erreurs 'cerr'. Cette fonction ajuste également le format de /// sortie pour correspondre à celui de Visual Studio afin d'intégrer /// l'exécution des tests au processus de compilation ("Post Build Event"). /// /// @return true si l'exécution de tous les tests a réussi, sinon false. /// //////////////////////////////////////////////////////////////////////// bool BancTests::executer() { // Obtenir la suite de tests à haut niveau CppUnit::Test *suite{ CppUnit::TestFactoryRegistry::getRegistry().makeTest() }; // Obtient un environnement d'exécution de tests qui imprime les résultats // dans une console (cout, cerr, fichier, etc.) et ajoute la suite de tests // de base à l'environnement. // (Notez qu'il est aussi possible d'obtenir un environnement qui affiche // les résultats des tests au sein d'une interface graphique QT ou MFC. // Consultez la documentation cppunit pour plus d'informations) CppUnit::TextUi::TestRunner runner; runner.addTest(suite); // Indique que nous souhaitons formatter la sortie selon un format qui // s'apparente à la sortie d'un compilateur (MSVC++), et que nous // souhaitons que la sortie soit réalisée dans le canal standard cerr. // Cela permettra à Visual Studio d'interpréter la sortie de cppunit, // d'indiquer les erreurs trouvées par les tests et leur numéro de ligne // en tant qu'erreurs survenant au niveau du processus de compilation. runner.setOutputter(new CppUnit::CompilerOutputter{ &runner.result(), std::cerr }); // Exécuter les tests return runner.run(); }
int main( int argc, char* argv[] ) { ProjetUnivers::Kernel::Parameters::load("kernel.config") ; ProjetUnivers::Kernel::Log::init() ; CppUnit::TextUi::TestRunner runner; CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest(registry.makeTest()); // Define the file that will store the XML output. std::ofstream outputFile("tests_kernel_automatic_registration.xml"); CppUnit::MultiOutputter* outputter = new CppUnit::MultiOutputter() ; outputter->add(new CppUnit::CompilerOutputter(&runner.result(),std::cerr)) ; outputter->add(new ProjetUnivers::Kernel::XmlOutputter(&runner,outputFile)) ; runner.setOutputter(outputter); // Run the test. bool wasSucessful = runner.run( "" ); ProjetUnivers::Kernel::Log::close() ; // Return error code 1 if the one of test failed. return wasSucessful ? 0 : 1; }
int main() { CppUnit::TextUi::TestRunner runner; // First add the tests from the named registries in the right order // To add/remove/modify a registry name, or to change its sequence // number, edit RegistryName.cpp for (std::vector<std::string>::const_iterator name = getRegistryNameList().begin(); getRegistryNameList().end() != name; ++name) { CppUnit::Test *namedSuite = CppUnit::TestFactoryRegistry::getRegistry(*name).makeTest(); runner.addTest(namedSuite); } // Add the top level (unnamed) suite from the list of tests to run CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); runner.addTest( suite ); // Change the default outputter to a compiler error format outputter runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); // Run the tests. bool wasSuccessful = runner.run(); // Return error code 1 if the one of test failed. return wasSuccessful ? 0 : 1; }
int main( int, char** argv) { CppUnit::TextUi::TestRunner runner; runner.addTest( AddressTableTest::suite() ); runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); runner.run(); return 0; }
int main(int argc, char* argv[]) { CppUnit::TextUi::TestRunner runner; runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); CppUnit::Outputter* outputter = new CppUnit::TextOutputter(&runner.result(), std::cout); runner.setOutputter(outputter); bool retcode = runner.run(); return !retcode; }
int main(int argc, const char* argv[]){ CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); CppUnit::TextUi::TestRunner runner; runner.addTest( suite ); runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr )); return runner.run() ? 0 : 1; }
int main(void) { CppUnit::TextUi::TestRunner runner; CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry("alltest"); ProgressListener listener; runner.addTest(registry.makeTest()); runner.eventManager().addListener(&listener); runner.run("", false, true, true); return runner.result().testFailuresTotal() ? 1 : 0; }
int main(int argc, char* argv[]) { QCoreApplication a(argc, argv); CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry(); CppUnit::TextUi::TestRunner runner; runner.addTest( registry.makeTest() ); if (argc >= 2 && !strcmp(argv[1],"--xml")) { runner.setOutputter(new CppUnit::XmlOutputter(&runner.result(), std::cout)); } return (runner.run("") ? 0 : 1); }
int main() { CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); CppUnit::TextUi::TestRunner runner; runner.addTest(suite); runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr)); bool wasSucessful(runner.run()); return wasSucessful ? 0 : 1; }
int main(int argc, const char* argv[]) { CppUnit::TextUi::TestRunner runner; runner.addTest(AutoBufferTest::suite()); runner.addTest(RawBufferTest::suite()); runner.run(argc, argv); return runner.result().testFailures(); }
int main(int argc, const char* argv[]) { CppUnit::TextUi::TestRunner runner; runner.addTest(StringListTest::suite()); runner.addTest(StringTokenizerTest::suite()); runner.run(argc, argv); return runner.result().testFailures(); }
int main(int argc, char* argv[]) { CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); CppUnit::TextUi::TestRunner runner; runner.addTest( suite ); runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); /** let the test run */ bool wasSucessful = runner.run(); /** check whether it was sucessfull or not */ return wasSucessful ? 0 : 1; }
int main(int argc, char* argv[]) { // Initialize digidoc library. digidoc::initialize(); // Make command line arguments globally available. for(int i = 0; i < argc; i++) { ARGS.push_back(argv[i]); } // Set test data path. if(ARGS.size() > 1) { std::string path = ARGS[1]; if(path[path.size() - 1] == '/' || path[path.size() - 1] == '\\') { path = path.substr(0, path.size() - 1); } TEST_DATA_PATH = path; } // Make sure that test data directory exists, otherwise some tests will fail. if(!digidoc::util::File::directoryExists(TEST_DATA_PATH)) { printf("WARNING: Test data path '%s' does not exist, some tests, that need test files will fail.\n", TEST_DATA_PATH.c_str()); if(ARGS.size() < 2) { printf("Please add test data path to command line (e.g. %s /path/to/test/data)", argv[0]); } } // Get the top level suite from the registry. CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); // Adds the test to the list of test to run. CppUnit::TextUi::TestRunner runner; runner.addTest(suite); // Change the default outputter to a compiler error format outputter. runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr)); // Run the tests. bool wasSucessful = runner.run(); // Terminate digidoc library. digidoc::terminate(); // Return error code 1 if the one of test failed. return wasSucessful ? 0 : 1; }
int main( int, char** argv) { //init(argv); init(); CppUnit::TextUi::TestRunner runner; runner.addTest( FWObjectTest::suite() ); runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); runner.run(); return 0; }
int main( int argc, char **argv) { CppUnit::TextUi::TestRunner runner; CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest( registry.makeTest() ); runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); CppUnit::BriefTestProgressListener listener; runner.eventManager().addListener(&listener); return runner.run() ? 0 : 1; }
int main(int argc, char* argv[]) { // Configure logging output brics_3d::Logger::setMinLoglevel(brics_3d::Logger::WARNING); /*see also: http://cppunit.sourceforge.net/doc/lastest/money_example.html#sec_running_test */ // Get the top level suite from the registry CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); // Adds the test to the list of test to run CppUnit::TextUi::TestRunner runner; runner.addTest(suite); // Check the set parameters. bool useXmlOutput = false; if (argc == 2) { std::string parameter = argv[1]; if (parameter.compare("--report-xml") == 0) { useXmlOutput = true; } } // Decide which output format to take. std::ofstream outputStream; if (useXmlOutput) { // Change the default outputter to a XML outputter outputStream.open("unit_test_results.xml"); runner.setOutputter(new CppUnit::XmlOutputter(&runner.result(), outputStream, std::string("ISO-8859-1"))); } else { // Change the default outputter to a compiler error format outputter runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr)); } // Run the tests. bool wasSucessful = runner.run(); // Return error code 1 if the one of test failed. return wasSucessful ? 0 : 1; }
void main(void) { CPPUNIT_TEST_SUITE_REGISTRATION(ModelDataTest); CPPUNIT_TEST_SUITE_REGISTRATION(ObjModelFileIOTest); CppUnit::TextUi::TestRunner runner; runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); CppUnit::Outputter* outputter = new CppUnit::TextOutputter(&runner.result(), std::cout); runner.setOutputter(outputter); runner.run(); }
int main( int argc, char** argv ) { // Get the top level suite from the registry CppUnit::Test* test_all = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); CppUnit::TextUi::TestRunner runner; runner.addTest( test_all ); // Change the default outputter to a compiler error format outputter runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); // Run the tests. Return 1 if a test didnt pass. return !runner.run(); }
int main() { cryptoplus::algorithms_initializer algorithms_initializer; cryptoplus::crypto_initializer crypto_initializer; CppUnit::Test* test = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); CppUnit::TextUi::TestRunner runner; runner.addTest(test); runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr)); return runner.run() ? EXIT_SUCCESS : EXIT_FAILURE; }
int main() { cout << "Execute openCONFIGURATOR unit tests - build on: " __DATE__ ", " __TIME__ << endl; // get the top-level suite of tests (registry is not the Win32 registry) CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); // add the test to the list of tests to run CppUnit::TextUi::TestRunner runner; runner.addTest(suite); // change the default outputter to a compiler error format outputter runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr)); // run the tests bool wasSuccessful = runner.run(); // return error code 1 if one or more tests failed return wasSuccessful ? 0 : 1; }
int main (int argc, char *argv[]) { // set up logger //log4cxx::BasicConfigurator::configure(); CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); if (argc == 1) registry.addRegistry("All"); else { // run just the specified tests for (int i=1; i<argc; i++) registry.addRegistry(argv[i]); } CppUnit::TextUi::TestRunner runner; runner.addTest(registry.makeTest()); // Errors have line numbers runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter( &runner.result(), std::cerr ) ); CppUnit::TestResult controller; CppUnit::TestResultCollector result; controller.addListener(&result); // register listener for per-test progress output // verbose, per-test output: test : OK CppUnit::BriefTestProgressListener progress; controller.addListener (&progress); runner.run(controller); // output stderr summary report CppUnit::TextOutputter compilerOutputter(&result, std::cerr); compilerOutputter.write(); // output xml report std::ofstream strm("result.xml"); CppUnit::XmlOutputter xmlOutputter(&result, strm); xmlOutputter.write(); return result.wasSuccessful() ? 0 : 1; }
int main(int argc, const char* argv[]){ CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); CppUnit::TextUi::TestRunner runner; tweak_output(output); if ( pipe2(worker.pipe, O_NONBLOCK) != 0){ /* non-block so it is possible to easily test that the pipe is actually empty */ abort(); } runner.addTest( suite ); runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr)); return runner.run() ? 0 : 1; }