Ejemplo n.º 1
0
int main( int argc, char* argv[])
{

	// informs test-listener about test-results
	CPPUNIT_NS::TestResult testResult;

	// register listener for collecting the test-results
	CPPUNIT_NS::TestResultCollector collectedResults;
	testResult.addListener( &collectedResults);

	// register listener for per-test progress output
	CPPUNIT_NS::BriefTestProgressListener progress;
	testResult.addListener( &progress);

	// insert test-suite at test-runner by registry
	CPPUNIT_NS::TestRunner testRunner;
	testRunner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
	testRunner.run(testResult);

	// important stuff happens next
	std::ofstream xmlFileOut("reports/testResults.xml");
	CPPUNIT_NS::XmlOutputter xmlOut( &collectedResults, xmlFileOut);
	xmlOut.write();

	// return 0 if tests were successful
	return collectedResults.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 2
0
int
main( int argc, char* argv[] )
{
	util::CLoggerMgr::Config(util::Log4Cxx);

  // Create the event manager and test controller
  CPPUNIT_NS::TextTestResult controller;

  // Add a listener that colllects test result
  CPPUNIT_NS::TestResultCollector result;
  controller.addListener( &result );        

  // Add a listener that print dots as test run.
  CPPUNIT_NS::BriefTestProgressListener progress;
  controller.addListener( &progress );      

  // Add the top suite to the test runner
  //CPPUNIT_NS::TextTestRunner runner;
  CPPUNIT_NS::TestRunner runner;
  runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
  runner.run( controller);

  // Print test in a compiler compatible format.
  CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
  outputter.write(); 

  util::CLoggerMgr::CleanLoggers();

  system("pause");
  return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 3
0
int main()
{
  // Create the event manager and test controller
  CPPUNIT_NS::TestResult controller;

  // Add a listener that colllects test result
  CPPUNIT_NS::TestResultCollector result;
  controller.addListener(&result);

  // Add a listener that print dots as test run.
  CPPUNIT_NS::BriefTestProgressListener progress;
  controller.addListener(&progress);

  // Add the top suite to the test runner
  CPPUNIT_NS::TestRunner runner;
  runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
  runner.run(controller);

  // output
  CPPUNIT_NS::CompilerOutputter outputter(&result, std::cerr);
  outputter.write();

  // return status code
  return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 4
0
int main(int argc, char *argv[])
{
	Logging::Logger::setGlobalLogger(new Logging::GenericLogger("testLogger"));

	// initialize the AlarmSystemInterfaceFactory
	ACSAlarmSystemInterfaceFactory::init(NULL);

	// Create the event manager and test controller
	CPPUNIT_NS::TestResult controller;

	// Add a listener that colllects test result
	CPPUNIT_NS::TestResultCollector result;
	controller.addListener( &result );

	// Add a listener that print dots as test run.
	CPPUNIT_NS::BriefTestProgressListener progress;
	controller.addListener( &progress );

	// Add the top suite to the test runner
	CPPUNIT_NS::TestRunner runner;
	runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
	runner.run( controller );

	// Print test in a compiler compatible format.
	std::cout.flush();
	CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
	outputter.write();

	// close the AlarmSystemInterfaceFactory
	ACSAlarmSystemInterfaceFactory::done();

	return result.wasSuccessful() ? 0 : 1;
}
int main(int argc, char* argv[])
{
    // Retrieve test path from command line first argument. Default to "" which resolve
    // to the top level suite.
    std::string testPath = (argc > 1) ? std::string(argv[1]) : std::string("");

    // Create the event manager and test controller
    CPPUNIT_NS::TestResult controller;

    // Add a listener that collects test result
    CPPUNIT_NS::TestResultCollector result;
    controller.addListener(&result);

    // Add a listener that print dots as test run.
    CPPUNIT_NS::BriefTestProgressListener progress;
    controller.addListener(&progress);

    // Add the top suite to the test runner
    CPPUNIT_NS::TestRunner runner;
    runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
    runner.run(controller);

    // Print test in a compiler compatible format.
    CPPUNIT_NS::CompilerOutputter outputter(&result, CPPUNIT_NS::stdCOut());
    outputter.write();

    // Uncomment this for XML output
    std::ofstream file("cppunit-report.xml");

    CPPUNIT_NS::XmlOutputter xml(&result, file);
    xml.write();
    file.close();

    return result.wasSuccessful() ? 0 : 1;
}
int main(int argc, char* argv[])
{
    // informs test-listener about testresults
    CPPUNIT_NS::TestResult testresult;

    // register listener for collecting the test-results
    CPPUNIT_NS::TestResultCollector collectedresults;
    testresult.addListener (&collectedresults);

    // register listener for per-test progress output
    CPPUNIT_NS::BriefTestProgressListener progress;
    testresult.addListener (&progress);

    // insert test-suite at test-runner by registry
    CPPUNIT_NS::TestRunner testrunner;
    testrunner.addTest (CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest ());
    testrunner.run(testresult);

    // output results in compiler-format
    CPPUNIT_NS::CompilerOutputter compileroutputter(&collectedresults, std::cerr);
    compileroutputter.write ();

    // Output XML for Jenkins CPPunit plugin
    ofstream xmlFileOut("cppTestBasicMathResults.xml");
    XmlOutputter xmlOut(&collectedresults, xmlFileOut);
    xmlOut.write();

    // return 0 if tests were successful
    return collectedresults.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 7
0
Archivo: main.cpp Proyecto: nyanp/STF
int main( int ac, char **av )
{

  // イベント・マネージャとテスト・コントローラを生成する
  CPPUNIT_NS::TestResult controller;

  // テスト結果収集リスナをコントローラにアタッチする
  CPPUNIT_NS::TestResultCollector result;
  controller.addListener( &result );

  // 「.」で進行状況を出力するリスナをアタッチする
  CPPUNIT_NS::BriefTestProgressListener progress;
  controller.addListener( &progress );

  // テスト・ランナーにテスト群を与え、テストする
  CPPUNIT_NS::TestRunner runner;
  runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
  runner.run( controller );

   // テスト結果を標準出力に吐き出す
  CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
  outputter.write();

  return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 8
0
int run_multi_cdn_strategy_test_case()
{
	// Create the event manager and test controller
	CPPUNIT_NS::TestResult controller;

	// Add a listener that colllects test result
	CPPUNIT_NS::TestResultCollector result;
	controller.addListener( &result );        

	// Add a listener that print dots as test run.
	CPPUNIT_NS::BriefTestProgressListener progress;
	controller.addListener( &progress );      

	// Add the top suite to the test runner
	CPPUNIT_NS::TestRunner runner;
	runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
	runner.run( controller );

	// Print test in a compiler compatible format.
	std::ofstream ofs("c:\\MultiCdnTestResult.txt");
	CPPUNIT_NS::CompilerOutputter outputter( &result, ofs );
	outputter.write(); 

	return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 9
0
int main( int argc, char **argv )
{
        argc = 0;
        std::cout << "Running " << argv[argc] << std::endl;

	// イベントマネージャを作成する
	CPPUNIT_NS::TestResult controller;

	// テスト結果を収集するオブジェクトを作成する
	CPPUNIT_NS::TestResultCollector result;
	controller.addListener( &result );        

	// テスト実行時に進行状況を表示するオブジェクトを作成する
	//CPPUNIT_NS::BriefTestProgressListener progress;
	//controller.addListener( &progress );

	// テストランナーにテストを設定する
	CPPUNIT_NS::TestRunner runner;
	runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry( ).makeTest( ) );
	runner.run( controller );

	// テスト結果を出力する
	CPPUNIT_NS::TextOutputter outputter( &result, std::cout );
	outputter.write( );

	// テストに成功した場合に 0 を返し,失敗したら 1 を返す
	return( result.wasSuccessful( ) ? 0 : 1 );
}
Ejemplo n.º 10
0
int main(int argc, char* argv[])
{
    // Create the event manager and test controller
    CPPUNIT_NS::TestResult controller;

    // Add a listener that colllects test result
    CPPUNIT_NS::TestResultCollector result;
    controller.addListener( &result );

    // Add a listener that print dots as test run.
    CPPUNIT_NS::BriefTestProgressListener progress;
    controller.addListener( &progress );

    // Add the top suite to the test runner
    CPPUNIT_NS::TestRunner runner;
    runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry("All Tests").makeTest() );
    runner.run( controller );

    // Print test in a text format.
    CPPUNIT_NS::TextOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
    outputter.write();

    // This for XML output
    std::ofstream file( "TestResult.xml" );
    CPPUNIT_NS::XmlOutputter xml( &result, file );
    xml.setStyleSheet( "report.xsl" );
    xml.write();
    file.close();

    return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 11
0
int
main( int, char ** )
{
    // create the event manager and test controller
    CPPUNIT_NS::TestResult controller;

    // add a listner that collects test results
    CPPUNIT_NS::TestResultCollector result;
    controller.addListener( &result );

    // add a listener that prints dots as test run.
    CPPUNIT_NS::BriefTestProgressListener progress;
    controller.addListener( &progress );

    //CPPUNIT_NS::TextTestProgressListener textprog;
    //controller.addListener( &textprog );

    // add the top suite to the test runner.
    CPPUNIT_NS::TestRunner runner;
    runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
    runner.run( controller );

    // output results in a compiler compatible format
    CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
    //CPPUNIT_NS::TextOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
    //CPPUNIT_NS::XmlOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
    outputter.write();

    return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 12
0
int main(int argc, char** argv)
{
  try
  {
    CPPUNIT_NS::TestResult controller;
    CPPUNIT_NS::TestResultCollector result;
    controller.addListener(&result);
    CPPUNIT_NS::BriefTestProgressListener progress;
    controller.addListener(&progress);
    CPPUNIT_NS::TestRunner runner;
    runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
    runner.run(controller);
    CPPUNIT_NS::CompilerOutputter outputter(&result, CPPUNIT_NS::stdCOut());
    outputter.write();
    return result.wasSuccessful() ? 0 : -1;
  }
  catch(const std::exception& exc)
  {
    std::cout << exc.what() << std::endl;
  }
  catch(...)
  {
    std::cout << "Unknown exception." << std::endl;
  }
  return -1;
}
Ejemplo n.º 13
0
int
main( int argc, char* argv[] )
{
  // Create the event manager and test controller
  CPPUNIT_NS::TestResult controller;

  // Add a listener that colllects test result
  CPPUNIT_NS::TestResultCollector result;
  controller.addListener( &result );        

  // Add a listener that print dots as test run.
  //CPPUNIT_NS::BriefTestProgressListener progress;
  //controller.addListener( &progress );      

  //controller.push
  
  // Add the top suite to the test runner
  CPPUNIT_NS::TestRunner runner;
  runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
  runner.run( controller );

  // Print test in a compiler compatible format.
  CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
  outputter.write();   
  
  return result.wasSuccessful() ? 0 : 1;
}
int main(void)
{
    // informs test-listener about testresults
    CPPUNIT_NS::TestResult testresult;

    // register listener for collecting the test-results
    CPPUNIT_NS::TestResultCollector collectedresults;
    testresult.addListener(&collectedresults);

    // register listener for per-test progress output
    CPPUNIT_NS::BriefTestProgressListener progress;
    testresult.addListener(&progress);

    // insert test-suite at test-runner by registry
    CPPUNIT_NS::TestRunner testrunner;
    testrunner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
    testrunner.run(testresult);

    // output results in compiler-format
    CPPUNIT_NS::CompilerOutputter compileroutputter(&collectedresults, std::cerr);
    compileroutputter.write();

    // return 0 if tests were successful
    return collectedresults.wasSuccessful() ? 0 : 1;
}
int runCppunitTestSuite(TestResultOutputType outputType)
{
    icl_core::os::lxrtStartup();
    icl_core::logging::initialize();

    // Informiert Test-Listener ueber Testresultate
    CPPUNIT_NS::TestResult testresult;

    // Listener zum Sammeln der Testergebnisse registrieren
    CPPUNIT_NS::TestResultCollector collectedresults;
    testresult.addListener(&collectedresults);

    // Test-Suite ueber die Registry im Test-Runner einfuegen
    CPPUNIT_NS::TestRunner testrunner;
    testrunner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());

    // Resultate ausgeben
    switch (outputType)
    {
    case eTROT_Text:
    {
        icl_core::TestListener progress;
        testresult.addListener(&progress);

        testrunner.run(testresult);

        CPPUNIT_NS::TextOutputter textoutputter(&collectedresults, std::cerr);
        textoutputter.write();
        break;
    }
    case eTROT_Compiler:
    {
        icl_core::TestListener progress;
        testresult.addListener(&progress);

        testrunner.run(testresult);

        CPPUNIT_NS::CompilerOutputter compileroutputter(&collectedresults, std::cerr);
        compileroutputter.write();
        break;
    }
    case eTROT_Xml:
    {
        testrunner.run(testresult);

        CPPUNIT_NS::XmlOutputter xmloutputter(&collectedresults, std::cerr, "UTF-8");
        xmloutputter.write();
        break;
    }
    }

    icl_core::logging::shutdown();
    icl_core::os::lxrtShutdown();

    // Rueckmeldung, ob Tests erfolgreich waren
    return collectedresults.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 16
0
Archivo: test.cpp Proyecto: poac/libs
int main( int argc, char **argv )

{

	// Create the event manager and test controller

	CPPUNIT_NS::TestResult controller;

	// Add a listener that colllects test result

/*	CPPUNIT_NS::TestResultCollector result;

	controller.addListener( &result );    */    
	CPPUNIT_NS::TestResultCollector result;

	controller.addListener( &result );        


	// Add a listener that print dots as test run.

	CPPUNIT_NS::BriefTestProgressListener progress;

	controller.addListener( &progress );      


	// Add the top suite to the test runner

	CPPUNIT_NS::TestRunner runner;

	runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );

	time_t tmbegin;
	time(&tmbegin);
	runner.run( controller );

	time_t tmend;
	time(&tmend);
	
	cout << "used time: " << tmend-tmbegin << endl;
	//CPPUNIT_NS::OStream *xmlStream = new CPPUNIT_NS::OFileStream( "report.xml" );

	//// Print test in a compiler compatible format.
	//CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
	//outputter.write(); 
	CPPUNIT_NS::CompilerOutputter outputter( &result,std::cout );
	outputter.write(); 
	//CPPUNIT_NS::XmlOutputter xmlOutputter( &result, *xmlStream );
	//xmlOutputter.setStyleSheet( "report.xsl" );
	//xmlOutputter.write(); 

	getchar();

	return 0/*result.wasSuccessful() ? 0 : 1*/;

}
Ejemplo n.º 17
0
int 
main( int argc, char* argv[] )
{
  // Retreive test path from command line first argument. Default to "" which resolve
  // to the top level suite.
  std::string testPath = (argc > 1) ? std::string(argv[1]) : std::string("");

  // Create the event manager and test controller
  CPPUNIT_NS::TestResult controller;

  // Add a listener that colllects test result
  CPPUNIT_NS::TestResultCollector result;
  controller.addListener( &result );        

  // Add a listener that print dots as test run.
#ifdef WIN32
  CPPUNIT_NS::TextTestProgressListener progress;
#else
  CPPUNIT_NS::BriefTestProgressListener progress;
#endif
  controller.addListener( &progress );      

  // Add the top suite to the test runner
  CPPUNIT_NS::TestRunner runner;
  runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );   
  try
  {
    std::string test_path = testPath.empty() ? " all unit tests" : testPath;
    std::cerr << "Running "  <<  test_path << std::endl;
    runner.run( controller, testPath );

    std::cerr << std::endl;

    // Print test in a compiler compatible format.
    CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
    outputter.write(); 

// Uncomment this for XML output
//    std::ofstream file( "tests.xml" );
//    CPPUNIT_NS::XmlOutputter xml( &result, file );
//    xml.setStyleSheet( "report.xsl" );
//    xml.write();
//    file.close();
  }
  catch ( std::invalid_argument &e )  // Test path not resolved
  {
    std::cerr  <<  std::endl  
               <<  "ERROR: "  <<  e.what()
               << std::endl;
    return 0;
  }

  return result.wasSuccessful() ? 0: 1;
}
Ejemplo n.º 18
0
int main(){
    CPPUNIT_NS::TestResult controller;
    CPPUNIT_NS::TestResultCollector result;
    controller.addListener( &result );       
    CPPUNIT_NS::BriefTestProgressListener progress;
    controller.addListener( &progress );     
    CPPUNIT_NS::TestRunner runner;
    runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
    runner.run( controller );

    return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 19
0
int main(int argc, const char * argv[])
{
	OptionsParser parser;
	if (parser.ParseOptions(argc, argv) < 0 || parser.m_Help) {
		parser.Usage(argv[0]);
		return -1;
	}

	if (parser.m_List) {
		CPPUNIT_NS::Test *test = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
		for (int i = 0; i < test->getChildTestCount(); i++) {
		  printf("test %s\n", test->getChildTestAt(i)->getName().c_str());
			for (int j = 0; j < test->getChildTestAt(i)->getChildTestCount(); j++) {
			  printf("test %s\n", test->getChildTestAt(i)->getChildTestAt(j)->getName().c_str());
			}
		}
		return 0;
	}

	CPPUNIT_NS::TestResult controller;

	// Add a listener that colllects test result
	CPPUNIT_NS::TestResultCollector result;
	controller.addListener( &result );

	// Add a listener that print dots as test run.
	CPPUNIT_NS::BriefTestProgressListener progress;
	controller.addListener( &progress );

	CPPUNIT_NS::TestRunner runner;
	// Add the single test to the test runner
	if (parser.m_RunSingle) {
		runner.addTest(
				CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest()->findTest(parser.m_TestName));
	// Add the top suite to the test runner
	} else {
		runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
	}

	runner.run( controller );

	// Print test in a compiler compatible format.
	CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
	outputter.write();

	return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 20
0
int main()
{
	GenericTest test;
	test.loadTile();
	CPPUNIT_NS::TestResult testResult;
	CPPUNIT_NS::TestResultCollector testsCollector;
	testResult.addListener(&testsCollector);
	CPPUNIT_NS::BriefTestProgressListener progress;
	testResult.addListener(&progress);
	CPPUNIT_NS::TestRunner runner;
	runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
	runner.run(testResult);
	CPPUNIT_NS::CompilerOutputter outCompiler(&testsCollector, std::cerr);
	outCompiler.write();

	return (testsCollector.wasSuccessful() ? 0 : 1);
}
Ejemplo n.º 21
0
int main()
{
    CPPUNIT_NS::TestResult tr;
    CPPUNIT_NS::TestResultCollector trc;
    tr.addListener(&trc);

    CPPUNIT_NS::BriefTestProgressListener progress;
    tr.addListener(&progress);

    CPPUNIT_NS::TestRunner runner;
    CPPUNIT_NS::TestFactoryRegistry &reg = CppUnit::TestFactoryRegistry::getRegistry("Test");
    runner.addTest(reg.makeTest());
    runner.run(tr);
    
    CPPUNIT_NS::CompilerOutputter outputter(&trc, CPPUNIT_NS::stdCOut());
    outputter.write();
}
Ejemplo n.º 22
0
int main(int argc, char* argv[])
{
	TCHAR strExePath[MAX_PATH];  
	memset(strExePath, 0, MAX_PATH);    
	GetModuleFileName(NULL, strExePath, MAX_PATH); 

	string strExeFile;
	short*p = (short*)strExePath;
	while (*p)
	{
		strExeFile += (char)(*p);
		p++;
	}

	g_strFilePath = strExeFile.substr(0, strExeFile.find("project")) + "testcase\\";

	// Create the event manager and test controller
    CPPUNIT_NS::TestResult controller;

    // Add a listener that colllects test result
    CPPUNIT_NS::TestResultCollector result;
    controller.addListener( &result );

    // Add a listener that print dots as test run.
    CPPUNIT_NS::BriefTestProgressListener progress;
    controller.addListener( &progress );

    // Add the top suite to the test runner
    CPPUNIT_NS::TestRunner runner;
    runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry("All Tests").makeTest() );
    runner.run( controller );

    // Print test in a text format.
    CPPUNIT_NS::TextOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
    outputter.write();

    // This for XML output
    std::ofstream file( "TestResult.xml" );
    CPPUNIT_NS::XmlOutputter xml( &result, file );
    xml.setStyleSheet( "report.xsl" );
    xml.write();
    file.close();

    return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 23
0
Archivo: Test.cpp Proyecto: Sija/swift
int _tmain(int argc, _TCHAR* argv[]) {
  CPPUNIT_NS::TestResult controller;

  CPPUNIT_NS::TestResultCollector result;
  controller.addListener(&result);

  CPPUNIT_NS::BriefTestProgressListener progress;
  controller.addListener(&progress);

  CPPUNIT_NS::TestRunner runner;
  runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
  runner.run(controller);

  CPPUNIT_NS::CompilerOutputter outputter(&result, std::cerr);
  outputter.write();

  return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 24
0
int main() {
    
    /* Options for outputs */
    int prec_def = 8;
    cout.precision(prec_def);
    //int wd = prec_def + 7;
    cout.setf(ios::floatfield);
    //cout.setf(ios::scientific);
    
    try {
        
        ////////////////////////////////////////////////////////////////////            
    
        // Create the event manager and test controller
        CPPUNIT_NS::TestResult controller;
        
        // Add a listener that colllects test result
        CPPUNIT_NS::TestResultCollector result;
        controller.addListener(&result);
        
        // Add a listener that print dots as test run.
        CPPUNIT_NS::BriefTestProgressListener progress;
        controller.addListener(&progress);
        
        // Add the top suite to the test runner
        CPPUNIT_NS::TestRunner runner;
        runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
        runner.run(controller);
        
        // Print test in a compiler compatible format.
        CPPUNIT_NS::CompilerOutputter outputter(&result, CPPUNIT_NS::stdCOut());
        outputter.write();
        
        return result.wasSuccessful() ? 0 : 1;

        
        ////////////////////////////////////////////////////////////////////        

        return EXIT_SUCCESS;
    } catch (const runtime_error& e) {
        cerr << e.what() << endl;
        return EXIT_FAILURE;
    }
}
Ejemplo n.º 25
0
int main( int argc, char* argv[] )
{
  // Create the event manager and test controller
  CPPUNIT_NS::TestResult controller;
  TimedTestListener ttlistener;

  // Add a listener that colllects test result
  CPPUNIT_NS::TestResultCollector result;
  controller.addListener( &result );        
  controller.addListener( &ttlistener);

  // Add a listener that print dots as test run.
  //CPPUNIT_NS::BriefTestProgressListener progress;
  //controller.addListener( &progress );      

  //controller.push
  
  // Add the top suite to the test runner
  CPPUNIT_NS::TestRunner runner;
  
  if ( argc == 1 ) {
	runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
  }
  if ( argc == 2 ) {
	  runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry(argv[1]).makeTest());
  }
  
  runner.run( controller );
  
  // Print test in a compiler compatible format.
  CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
  outputter.write();   

  //XML Output
  std::ofstream xmlFileOut("cpptestresults.xml");
  CPPUNIT_NS::XmlOutputter xmlOut(&result, xmlFileOut);

  XmlTimedTestOutputterHook *xmlTimeHook = new   XmlTimedTestOutputterHook(&ttlistener);
  xmlOut.addHook(xmlTimeHook);
  xmlOut.write();
  delete xmlTimeHook;
  return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 26
0
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		cerr << _T("Fatal Error: MFC initialization failed") << endl;
		nRetCode = 1;
	}
	else
	{
		/**
		 * This is the code running the tests.
		 * Tests are found automatically once they are created with
		 * CppUnit's macros, you don't need to run single tests here.
		 */
		CPPUNIT_NS::TestResult controller;

		// Add a listener that colllects test result
		CPPUNIT_NS::TestResultCollector result;
		controller.addListener( &result );

		// Add a listener that print dots as test run.
		CPPUNIT_NS::BriefTestProgressListener progress;
		controller.addListener( &progress );

		// Add the top suite to the test runner
		CPPUNIT_NS::TestRunner runner;
		runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
		runner.run( controller );

		// Print test in a compiler compatible format.
		CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
		outputter.write();
	}

	// Wait for user...
	getc(stdin);

	return nRetCode;
}
Ejemplo n.º 27
0
int main( int ac, char **av )
{
  //--- Create the event manager and test controller
  CPPUNIT_NS::TestResult controller;

  //--- Add a listener that colllects test result
  CPPUNIT_NS::TestResultCollector result;
  controller.addListener( &result );        

  //--- Add a listener that print dots as test run.
  CPPUNIT_NS::BriefTestProgressListener progress;
  controller.addListener( &progress );      

  //--- Add the top suite to the test runner
  CPPUNIT_NS::TestRunner runner;
  runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
  runner.run( controller );

  return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 28
0
int main(int argc, char* argv[])
{
	// Create the event manager and test controller
	CppUnit::TestResult controller;

	// Add a listener that colllects test result
	CppUnit::TestResultCollector result;
	controller.addListener( &result );

	// Add a listener that print dots as test run.
	CppUnit::TextTestProgressListener progress;
	controller.addListener( &progress );

	// Add the top suite to the test runner
	CppUnit::TestRunner runner;
	runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() );   

	try
	{
		std::cout << "Running ";
		CPPUNIT_NS::TestRunner runner;
		runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
		runner.run( controller );

		std::cerr << std::endl;

		// Print test in a compiler compatible format.
		CppUnit::CompilerOutputter outputter( &result, std::cerr );
		outputter.write();
		cin.get();
	}
	catch ( std::invalid_argument &e )  // Test path not resolved
	{
		std::cerr  <<  std::endl  
			<<  "ERROR: "  <<  e.what()
			<< std::endl;
		return 0;
	}

	return result.wasSuccessful() ? 0 : 1;
}
Ejemplo n.º 29
0
using namespace std

int main() {
    
    CPPUNIT_NS::TestResult controller;
    
    CPPUNIT_NS::TestResultCollector result;
    controller.addListener( &result ); 

    CPPUNIT_NS::BriefTestProgressListener progress;
    controller.addListener( &progress );   
    
    CPPUNIT_NS::TestRunner runner;
    runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
    runner.run( controller );
    
    CPPUNIT_NS::CompilerOutputter outputter( &result,CPPUNIT_NS::stdCOut() );
    outputter.write();   
    
    return 0;
}
Ejemplo n.º 30
0
int CppUnitTestRunner::Run(std::vector<CPPUNIT_NS::Test *>& tests)
{
    CPPUNIT_NS::TestRunner					runner;
    CPPUNIT_NS::TestResult					controller;
    CPPUNIT_NS::TestResultCollector			result;
    CPPUNIT_NS::BriefTestProgressListener	progress;
    CPPUNIT_NS::CompilerOutputter			outputter( &result, std::cerr );
    std::string								xmlFileName   = (s_XmlPath=="" ? "" : s_XmlPath + "\\") + m_TestSuiteName + ".xml";
    std::ofstream							output_file( xmlFileName.c_str() , std::ios::out );
    CPPUNIT_NS::XmlOutputter                 xmloutputter( &result, output_file );

    controller.addListener( &result );        
    controller.addListener( &progress );      

    for each (CPPUNIT_NS::Test * test in tests)
        runner.addTest(test);

    runner.run( controller );

    outputter.write();
    xmloutputter.write();

    return result.wasSuccessful() ? EXIT_SUCCESS : EXIT_FAILURE;
}