• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cppunit::TestRunner类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cppunit::TestRunner的典型用法代码示例。如果您正苦于以下问题:C++ TestRunner类的具体用法?C++ TestRunner怎么用?C++ TestRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TestRunner类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char ** argv) {
	Util::init();

	const std::string testPath = (argc > 1) ? std::string(argv[1]) : "";

	CppUnit::TestResult controller;

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

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

	CppUnit::TestRunner runner;
	runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());

	runner.run(controller, testPath);

	std::ofstream fileStream("cppunit_results.xml");
	CppUnit::XmlOutputter xmlOutput(&result, fileStream, "UTF-8");
	xmlOutput.write();

	CppUnit::TextOutputter textOutput(&result, std::cout);
	textOutput.write();

	return result.wasSuccessful() ? 0 : 1;
}
开发者ID:ofaismail,项目名称:Util,代码行数:27,代码来源:UtilTestMain.cpp


示例2: main

int main( int argc, char *argv[] ) {
	// informs test-listener about testresults
	CppUnit::TestResult testresult;

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

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

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

	// writing result on a XML file
	std::ofstream xmlFileOut( "testresults.xml" );
	CppUnit::XmlOutputter xmlOut(&collectedresults, xmlFileOut);
	xmlOut.write();

	// return 0 if tests were successful
	return collectedresults.wasSuccessful() ? 0 : 1;
}
开发者ID:LCLS,项目名称:OpenMMFBM,代码行数:25,代码来源:main.cpp


示例3: main

int main(int /*argc*/, char ** /*argv*/) {
	Util::init();
	
	CppUnit::TestResult controller;

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

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

	CppUnit::TestRunner runner;
	runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());

	runner.run(controller);

	std::ofstream fileStream("cppunit_results.xml");
	CppUnit::XmlOutputter xmlOutput(&result, fileStream, "UTF-8");
	xmlOutput.write();

	CppUnit::TextOutputter textOutput(&result, std::cout);
	textOutput.write();

	return 0;
}
开发者ID:evildr,项目名称:Util,代码行数:25,代码来源:UtilTestMain.cpp


示例4: main

int main (int argc, char* argv[])
{
    // informs test-listener about testresults
    CppUnit::TestResult testresult;

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

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

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

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

    // return 0 if tests were successful
    return collectedresults.wasSuccessful () ? 0 : 1;
}
开发者ID:gfordyce,项目名称:stan,代码行数:25,代码来源:test_runner.cpp


示例5: main

int main( int argc, char** argv )
{
    // informs test-listener about testresults
    CppUnit::TestResult controller;

    // register listener for collecting the test-results
    CppUnit::TestResultCollector result;
    controller.addListener( &result );

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

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

    if( argc > 1 )
    {
        testrunner.run( controller, argv[1] );
    }
    else
    {
        testrunner.run( controller, "" );
    }

    // output results in compiler-format
    CppUnit::CompilerOutputter compileroutputter( &result, std::cerr );
    compileroutputter.write();
}
开发者ID:kneufeld,项目名称:mt_circular_buffer,代码行数:30,代码来源:mt_circular_buffer_tests.cpp


示例6: main

int main() {
  // Create the event manager and test controller
  CppUnit::TestResult controller;

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

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

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

  CppUnit::TextOutputter output(&result, std::cout);
  std::cout << std::endl
      << "==================================================" << std::endl
      << "Papyrus Library Unit Tests: " << std::endl;
  output.printHeader();
  output.printStatistics();
  output.printFailures();

  return result.wasSuccessful() ? 0 : 1;
}
开发者ID:scott--,项目名称:papyrus,代码行数:27,代码来源:papyrus_unit_tests.cpp


示例7: run

bool TestRunner::run()
{
    CppUnit::TestRunner *pthis = this;
    pthis->run(*m_result);
    m_outputter->write();

    return m_monitor->wasSuccessful();
}
开发者ID:mranga,项目名称:sipxecs,代码行数:8,代码来源:TestRunner.cpp


示例8: main

int main(int ac, char **av)
{
	CryptoInitializer ci;
	
	std::vector<std::string> args;
	for (int i = 0; i < ac; ++i)
		args.push_back(std::string(av[i]));
	CppUnit::TestRunner runner;
	runner.addTest("CryptoTestSuite", CryptoTestSuite::suite());
	return runner.run(args) ? 0 : 1;
}
开发者ID:babafall,项目名称:Sogeti-MasterThesis-CrossPlatformMobileDevelopment,代码行数:11,代码来源:Driver.cpp


示例9: main

int main(int argc, char* argv[])
{
  std::string testPath = (argc > 1) ? std::string(argv[1]) : "";

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

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

  // Add a listener that print dots as test run.
  CppUnit::BriefTestProgressListener 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 "  << testPath;
    runner.run(controller, testPath);

    std::cerr << std::endl;

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

#if defined(_MSC_VER) && _MSC_VER > 1500
    char *xml = NULL;
    ::_dupenv_s(&xml, NULL, "CPPUNIT_XML");
#else
    char *xml = ::getenv("CPPUNIT_XML");
#endif
    if(xml && !::strcmp(xml, "1")) {
      std::ofstream xmlfileout("cpptestresults.xml");
      CppUnit::XmlOutputter xmlout(&result, xmlfileout);
      xmlout.write();
    }
#if defined(_MSC_VER) && _MSC_VER > 1500
    ::free(xml);
#endif
  }
  catch(std::invalid_argument &e){
    std::cerr << std::endl
              << "ERROR: " << e.what()
              << std::endl;
    return 0;
  }

  return result.wasSuccessful() ? 0 : 1;
}
开发者ID:DiodeZ,项目名称:taglib,代码行数:53,代码来源:main.cpp


示例10: runPlugin

bool runPlugin(const CommandLineParser &arguments) {
	CppUnit::PlugInManager pluginManager;
	pluginManager.load(arguments.plugName);

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

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

	// Add a listener
	CppUnit::BriefTestProgressListener progress;
	controller.addListener(&progress);

	pluginManager.addListener(&controller);

	// Add the top suite to the test runner
	CppUnit::TestRunner runner;
	runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
	try
	{
		if (arguments.testPaths.empty()) {
			std::cout << "Running " << std::endl;
			runner.run(controller);
		}
		else {
			for (const auto & p : arguments.testPaths) {
				std::cout << "Running " << p << std::endl;
				runner.run(controller, p);
			}
		}
		std::cerr << std::endl;

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

        if (!arguments.xmlOutputFile.empty()) {
            std::ofstream file(arguments.xmlOutputFile);
            CppUnit::XmlOutputter xOutputter(&result, file);
            xOutputter.write();
        }
	}
	catch (std::invalid_argument &e)  // Test path not resolved
	{
		std::cerr << std::endl
			<< "ERROR: " << e.what()
			<< std::endl;
		return false;
	}
	return result.wasSuccessful();
}
开发者ID:k-brac,项目名称:CUTI,代码行数:53,代码来源:CutiMain.cpp


示例11: main

int main(int argc, char* argv[])
{
	// VMime initialization
	vmime::platform::setHandler<vmime::platforms::posix::posixHandler>();

	// Parse arguments
	bool xmlOutput = false;

	for (int c = 1 ; c < argc ; ++c)
	{
		const std::string arg = argv[c];

		if (arg == "--xml")
			xmlOutput = true;
	}

	// Run the tests
	if (xmlOutput)
	{
		// Get the test suites from the registry and add them to the list of tests to run
		CppUnit::TestRunner runner;

		for (unsigned int i = 0 ; i < getTestModules().size() ; ++i)
		{
			runner.addTest(CppUnit::TestFactoryRegistry::
				getRegistry(getTestModules()[i]).makeTest());
		}

		std::auto_ptr <XmlTestListener> xmlListener(new XmlTestListener);

		CppUnit::TestResult controller;
		controller.addListener(xmlListener.get());

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

		runner.run(controller);

		xmlListener->output(std::cout);

		// Return error code 1 if a test failed
		return result.wasSuccessful() ? 0 : 1;
	}
	else
	{
		// Get the top level suite from the registry
		CppUnit::TextUi::TestRunner runner;
		runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());

		return runner.run() ? 0 : 1;
	}
}
开发者ID:EugeneVolkorez,项目名称:vmime,代码行数:52,代码来源:testRunner.cpp


示例12: wmain

int wmain(int argc, wchar_t* argv[])
{
	std::vector<std::string> args;
	for (int i = 0; i < argc; ++i)
	{
		char buffer[1024];
		std::wcstombs(buffer, argv[i], sizeof(buffer));
		args.push_back(std::string(buffer));
	}
	CppUnit::TestRunner runner;	
	runner.addTest("FoundationTestSuite", FoundationTestSuite::suite());
	return runner.run(args) ? 0 : 1;
}
开发者ID:marianovolker,项目名称:jmps-public,代码行数:13,代码来源:WinCEDriver.cpp


示例13: AddTest

 // call List() if m_list or runner.addTest() otherwise
 void AddTest(CppUnit::TestRunner& runner, Test *test)
 {
     if (m_list)
         List(test);
     else
         runner.addTest(test);
 }
开发者ID:gdos,项目名称:wxWidgets,代码行数:8,代码来源:test.cpp


示例14: main

int main()
{
	CppUnit::TestResult r;
	CppUnit::TestResultCollector rc;
	r.addListener(&rc); // 准备好结果收集器

	CppUnit::TestRunner runner; // 定义执行实体
	runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("alltest").makeTest());
	runner.run(r); // 运行测试

	CppUnit::TextOutputter o(&rc, std::cout);
	o.write(); // 将结果输出

	//system("pause");

	return rc.wasSuccessful() ? 0 : -1;
}
开发者ID:RTCSD15,项目名称:Team1,代码行数:17,代码来源:testmain.cpp


示例15: main

int main(int argc, char* argv[])
{
    CppUnit::TestRunner runner;

    CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();

    runner.addTest( registry.makeTest() );

    CppUnit::TestResult controller;
    CppUnit::TestResultCollector result;
    controller.addListener(&result);

    runner.run(controller);

    CustomOutputter outputter(&result, std::cerr);

    outputter.write();

    return result.wasSuccessful() ? 0 : 1;
}
开发者ID:emdeesee,项目名称:rct,代码行数:20,代码来源:main.cpp


示例16: runTest

int runTest(const std::string& testName, int argc, char* argv[])
{
	DebugFilter::shouldWriteToConsole(false);

	for (int i = 1; i < argc; ++i)
	{
		if ((strcmp("-v", argv[i]) == 0) || (strcmp("--verbose", argv[i]) == 0))
		{
			DebugFilter::shouldWriteToConsole(true);
		}
	}

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

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

#if 0 // original CppUnit progress listener
	// Add a listener that print dots as test run.
	CppUnit::TextTestProgressListener progress;
#else
	BWTestProgressListener progress;
#endif

	controller.addListener(&progress);

	CppUnit::TestRunner runner;
	runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());

	BWUnitTest::unitTestInfo("Running %s:\n", testName.c_str());
	runner.run(controller);
	BWUnitTest::unitTestError("\n");

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

	return result.testFailures();
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:41,代码来源:unit_test.cpp


示例17: main

int main( int argc, char* argv[] )
{
    string xmlPath = "";
    string currentParse = "";
    for( int i = 1; i < argc; i++ ){
        string s = argv[i];
        if( s.substr( 0, 1 ) == "-" ){
            currentParse = s;
        }else{
            if( currentParse == "-o" ){
                xmlPath = s;
            }else if( currentParse == "-f" ){
                TestUtil::setFixtureRootPath( s );
            }
            currentParse = "";
        }
    }
    CppUnit::TestResult controller;
    CppUnit::TestResultCollector results;
    controller.addListener( &results );

    CppUnit::BriefTestProgressListener progress;
    if( xmlPath.size() == 0 ){
        controller.addListener( &progress );
    }

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

    if( xmlPath.size() == 0 ){
        CppUnit::CompilerOutputter outputter( &results, CppUnit::stdCOut() );
        outputter.write();
    }else{
        std::ofstream ofs( xmlPath.c_str() );
        CppUnit::XmlOutputter outputter( &results, ofs, "UTF-8" );
        outputter.write();
    }

    return results.wasSuccessful() ? 0 : 1;
}
开发者ID:cadencii,项目名称:cadencii-nt,代码行数:41,代码来源:main.cpp


示例18: main

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;
}
开发者ID:SeanNguyen,项目名称:cs3202-team-4-repo,代码行数:41,代码来源:UnitTest.cpp


示例19: main

int main( int argc, char* argv[] )
{
    std::string testPath = (argc > 1) ? std::string( argv[1] ) : "";

    // 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 {
        clock_t t = clock();
        
        std::cout << "Unit running " <<  testPath;
        runner.run( controller, testPath );

        std::cerr << std::endl;

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

        double dt = ((double) clock() - t) / CLOCKS_PER_SEC;
        std::cout << "Timed: " << dt << "s" << std::endl;
    }
    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;
}
开发者ID:nickmat,项目名称:HistoryCal,代码行数:40,代码来源:testmain.cpp


示例20: main

int main (int argc, char* argv[])
{
  // stores test results (listener)
  CppUnit::TestResult testresult;
  CppUnit::TestResultCollector collectedresults;
  testresult.addListener (&collectedresults);

  // get testsuit and add it to our TestRunner
  CppUnit::TestRunner tester;
  tester.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());

  // run unit tests
 tester.run(testresult);

  // format results in a nice compiler friendly format
  CppUnit::CompilerOutputter compileroutputter( &collectedresults, 
                                                std::cout);
  compileroutputter.write ();

  // returns 0 on success
  return collectedresults.wasSuccessful () ? 0 : 1;
}
开发者ID:HerrPeterPaul,项目名称:anna,代码行数:22,代码来源:main.cpp



注:本文中的cppunit::TestRunner类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cppunit::TestSuite类代码示例发布时间:2022-05-31
下一篇:
C++ cppunit::TestResultCollector类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap