本文整理汇总了C++中cppunit_ns::TestResult::addListener方法的典型用法代码示例。如果您正苦于以下问题:C++ TestResult::addListener方法的具体用法?C++ TestResult::addListener怎么用?C++ TestResult::addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cppunit_ns::TestResult
的用法示例。
在下文中一共展示了TestResult::addListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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;
}
示例2: main
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 ®istry( 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;
}
示例3: main
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;
}
示例4: main
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;
}
示例5: main
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;
}
示例6: run_multi_cdn_strategy_test_case
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;
}
示例7: main
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;
}
示例8: main
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;
}
示例9: main
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;
}
示例10: main
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;
}
示例11: main
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;
}
示例12: outputter
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;
}
示例13: main
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;
}
示例14: main
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;
}
示例15: main
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;
}