Пример #1
0
    Framework::ReturnCode Framework::run() {
        Ensures(m_program_options.parse_options());

        if (m_program_options.asked_for_help()) {
            return help();
        }

        if (m_program_options.asked_for_list()) {
            return list();
        }

        CPPUNIT_NS::TextUi::TestRunner runner;

        if (m_program_options.asked_to_run_only_some_tests()) {
            Ensures(combine_tests_subset(runner));
        } else if (m_program_options.asked_for_regtest()) {
            Ensures(combine_regtest_subset(runner));
        } else {
            runner.addTest(get_registry()->makeTest());
        }

        CPPUNIT_NS::TestResult controller;

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

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

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

        return result.wasSuccessful() ? SUCCESS : FAILURE;
    }
Пример #2
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;
}
Пример #3
0
int main(int argc, char**const argv)
{
#ifndef _WIN32
	setenv("SOFTHSM2_CONF", "./softhsm2.conf", 1);
#else
	setenv("SOFTHSM2_CONF", ".\\softhsm2.conf", 1);
#endif

	CPPUNIT_NS::TestFactoryRegistry &registry( CPPUNIT_NS::TestFactoryRegistry::getRegistry() );

	CPPUNIT_NS::TextTestRunner runner;
	runner.addTest(registry.makeTest());
	if ( argc<2 ) {
		return runner.run() ? 0 : 1;
	}
	if ( std::string("direct").find(*(argv+1))==std::string::npos ) {
		return runner.run(*(argv+1)) ? 0 : 1;
	}
	runner.addTest(registry.makeTest());
	CPPUNIT_NS::TestResult controller;
	CPPUNIT_NS::TestResultCollector result;
	controller.addListener( &result );
	MyListener progress;
	controller.addListener( &progress );

	runner.run(controller);
	return result.wasSuccessful() ? 0 : 1;
}
Пример #4
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;
}
Пример #5
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;
}
Пример #7
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;
}
Пример #8
0
int main(int ac,char **av)
{
    enable_logging = 1;

   // 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 );

  
   CppUnit::TextUi::TestRunner runner;
   // Add the top runner.to the test runner
    runner.addTest( CCalendarProcs_TS1::suite() );
//     runner.addTest(new CppUnit::TestCaller<ValidCTodoConstructorTestCase>(
//  			   "test_validCTodoConstructor",
//  			   &ValidCTodoConstructorTestCase::test_validCTodoConstructor));
   runner.run( controller );
 
   // Print test in a compiler compatible format.
   std::ofstream file("dbprocs.xml");
   CPPUNIT_NS::XmlOutputter xml( &result, file );
   xml.setStyleSheet( "report.xsl" );
   xml.write();
   file.close();
   return result.wasSuccessful() ? 0 : 1;
                               
}
Пример #9
0
Файл: main.cpp Проект: 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;
}
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;
}
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;
}
Пример #12
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().makeTest() );
  runner.run( controller );

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

  getchar();

  return result.wasSuccessful() ? 0 : 1;
}
Пример #13
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;
}
Пример #14
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;
}
Пример #15
0
int main(int argc, char* argv[])
{
	std::string testPath = (argc > 1) ? std::string(argv[1]) : std::string("");

	CPPUNIT_NS::TestResult controller;

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

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

	CppUnit::TextUi::TestRunner runner;
	CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
	runner.addTest(registry.makeTest());

	try
	{
		CPPUNIT_NS::stdCOut() << "Running " << testPath;
		runner.run(controller, testPath);
		CPPUNIT_NS::stdCOut() << "\n";

		CPPUNIT_NS::CompilerOutputter outputter(&result, CPPUNIT_NS::stdCOut());
		outputter.write();
	}
	catch( std::invalid_argument& e)
	{
		CPPUNIT_NS::stdCOut() << "\n" << "ERROR: " << e.what() << "\n";	
	}

	return result.wasSuccessful() ? 0 : 1;
}
Пример #16
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;
}
Пример #17
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 );

  
   CppUnit::TextUi::TestRunner runner;
   // Add the top runner.to the test runner
   runner.addTest( CTimezone_TS1::suite() );
   runner.run( controller );
 
   // Print test in a compiler compatible format.
   std::ofstream file("ctimezone.xml");
   CPPUNIT_NS::XmlOutputter xml( &result, file );
   xml.setStyleSheet( "report.xsl" );
   xml.write();
   file.close();

   return result.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;
}
Пример #19
0
Файл: test.cpp Проект: 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*/;

}
Пример #20
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;
}
Пример #21
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;
}
Пример #22
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 );
}
Пример #23
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;
}
Пример #24
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);
}
Пример #25
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();
}
Пример #26
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;
}
Пример #27
0
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;
}
Пример #28
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;
    }
}
Пример #29
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;
}
Пример #30
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;
}