本文整理汇总了C++中cppunit::textui::TestRunner::run方法的典型用法代码示例。如果您正苦于以下问题:C++ TestRunner::run方法的具体用法?C++ TestRunner::run怎么用?C++ TestRunner::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cppunit::textui::TestRunner
的用法示例。
在下文中一共展示了TestRunner::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompilerOutputter
int
main(int argc, char **argv) {
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
CppUnit::CompilerOutputter *outputter =
new CppUnit::CompilerOutputter(&runner.result(), std::cout);
outputter->setLocationFormat("%p(%l) : ");
//outputter->setWrapColumn(19);
outputter->setNoWrap();
runner.setOutputter(outputter);
bool wasSuccessful = runner.run("",
false, // doWait
true, // doPrintResult
true // doPrintProgress
);
return !wasSuccessful;
}
示例2: main
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
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
std::cerr ) );
// Run the test.
bool wasSucessful = runner.run();
// Return error code 1 if the one of test failed.
return wasSucessful ? 0 : 1;
}
示例3: getopt
int main(int argc, char *argv[]) {
#if ENABLE_CORBA
Astro::OrbSingleton orb(argc, argv);
#endif /* ENABLE_CORBA */
int c;
while (EOF != (c = getopt(argc, argv, "d")))
switch (c) {
case 'd':
debuglevel = LOG_DEBUG;
break;
}
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry
= CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest(registry.makeTest());
bool wasSuccessful = runner.run("", false);
return (wasSuccessful) ? 0 : 1;
}
示例4: main
int main(){
CPPUNIT_TEST_SUITE_REGISTRATION(BookTest);
//if to devide tests in unit
//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION();
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry ();
runner.addTest(registry.makeTest());
/*
//replace this
CppUnit::TextUi::TestRunner runner;
runner.addTest(BookTest::suite());
*/
if(runner.run()){
return 0;
}else{
return 1;
}
}
示例5: runTests
/*
void runTests()
{
QxCppUnit::TestRunner runner;
runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() );
runner.run( );
}
*/
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 ) );
bool wasSucessful = runner.run();
return wasSucessful ? 0 : 1;
// Create the QtTestRunner:
// QApplication app(argc, argv);
// runTests();
// return app.exec();
}
示例6: main
// If TestSuite is not changes, the following code don't need to change.
int main()
{
CppUnit::TestResult r;
CppUnit::TestResultCollector listener;
CppUnit::TestResultCollector result;
r.addListener(&listener);
r.addListener(&result);
CppUnit::TextUi::TestRunner runner;
//Get test suit.
CppUnit::Test *test = CppUnit::TestFactoryRegistry::getRegistry("alltest").makeTest();
// Add this test suit to test runner.
runner.addTest( test );
//output log to run.log file.
std::ofstream ofile;
ofile.open("run.log");
CppUnit::TextOutputter outputter(&listener, ofile);;
//This would occur code dumped.reason unkonwn.
//runner.setOutputter(&outputter);
//output result to result.xml.
std::ofstream file( "result.xml" );
CppUnit::XmlOutputter xml( &result, file );
//run the test runner.
runner.run(r);
//write to file.
outputter.write();
xml.write();
//close ofstream.
ofile.close();
file.close();
//output test results to console.
CppUnit::TextOutputter o(&listener, std::cout);
o.write();
return listener.wasSuccessful() ? 0 : -1;
}
示例7:
int
main(int argc, char *argv[])
{
CppUnit::TextUi::TestRunner runner;
runner.addTest(BoilerplateTest::suite());
runner.addTest(BolStateTest::suite());
runner.addTest(CharSourceTest::suite());
runner.addTest(CKeywordTest::suite());
runner.addTest(CMetricsCalculatorTest::suite());
runner.addTest(CyclomaticTest::suite());
runner.addTest(DescriptiveTest::suite());
runner.addTest(HalsteadTest::suite());
runner.addTest(NestingLevelTest::suite());
runner.addTest(QualityMetricsTest::suite());
runner.run();
return 0;
}
示例8: main
int main(int /*argc*/, char** /*argv*/)
{
CppUnit::TestResult controller;
CppUnit::TestResultCollector result;
CppUnit::TextUi::TestRunner runner;
controller.addListener(&result);
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest(registry.makeTest());
runner.run(controller);
std::ofstream xmlFileOut("test-results.xml");
CppUnit::XmlOutputter xmlOut(&result, xmlFileOut);
xmlOut.write();
CryptoFactory::reset();
return result.wasSuccessful() ? 0 : 1;
}
示例9: StartUnitTest
FRAME_ROOMSERVER_NAMESPACE_BEGIN
int StartUnitTest()
{
//CTestCaseUtil testUtil;
//testUtil.RunTestCase1();
CppUnit::TextUi::TestRunner runner;
//CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
// Adds the test to the list of test to run
//runner.addTest( suite );
//std::fstream fileRead("vibrancyserver.ini");//open file
//std::string strLine;
//while (getline(fileRead,strLine))//read line in file until end
//{
// CppUnit::TestFactoryRegistry ®= CppUnit::TestFactoryRegistry::getRegistry(strLine.c_str());
// runner.addTest(reg.makeTest());
//}
//fileRead.close();
std::ifstream ifs("roomserver.ini");
std::string strLine;
while (ifs >> strLine)
{
CppUnit::TestFactoryRegistry ®= CppUnit::TestFactoryRegistry::getRegistry(strLine.c_str());
runner.addTest(reg.makeTest());
}
//CppUnit::TestFactoryRegistry ®= CppUnit::TestFactoryRegistry::getRegistry("vibrancyserver");
//runner.addTest(reg.makeTest());
// Change the default outputter to a compiler error format outputter
std::ofstream file("roomserver_testresult.log");
//runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),std::cerr ) );
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),file ) );
// Run the tests.
bool wasSucessful = runner.run();
return 0;
}
示例10: main
int main(int argc, char* argv[])
{
try {
spdlog::level::level_enum level = spdlog::level::info;
std::vector<spdlog::sink_ptr> sinks;
sinks.push_back(std::make_shared<spdlog::sinks::stdout_sink_st>());
spdlog::set_level(level);
// if new logger required, must add to here!
const char *loglist[] = {
"main",
"ClientConnection",
"ServerListener",
"LinearMemoryPool",
"BlockedMemoryPool",
"UserSession",
""
};
for (int i = 0; strcmp("", loglist[i]) != 0; i++) {
auto combined_logger = std::make_shared<spdlog::logger>(loglist[i], begin(sinks), end(sinks));
combined_logger->set_level(level);
spdlog::register_logger(combined_logger);
}
} catch (const spdlog::spdlog_ex& ex) {
cerr << "Log failed: " << ex.what() << endl;
}
// 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();
// Return error code 1 if the one of test failed.
return wasSucessful ? 0 : 1;
}
示例11: main
int main(int argc, char *argv[])
{
CppUnit::TextUi::TestRunner runner;
CppUnit::TestSuite *suite = new CppUnit::TestSuite();
suite->addTest(new CppUnit::TestCaller<Reverse_IntegerTest>(
"test1", &Reverse_IntegerTest::test1));
suite->addTest(new CppUnit::TestCaller<Reverse_IntegerTest>(
"test2", &Reverse_IntegerTest::test2));
suite->addTest(new CppUnit::TestCaller<Reverse_IntegerTest>(
"test3", &Reverse_IntegerTest::test3));
suite->addTest(new CppUnit::TestCaller<Reverse_IntegerTest>(
"test4", &Reverse_IntegerTest::test4));
suite->addTest(new CppUnit::TestCaller<Reverse_IntegerTest>(
"test5", &Reverse_IntegerTest::test5));
runner.addTest(suite);
runner.run("", true);
return 0;
}
示例12: main
int main(int argc, char** argv)
{
CppUnit::TextUi::TestRunner
runner; // Control tests.
CppUnit::TestFactoryRegistry&
registry(CppUnit::TestFactoryRegistry::getRegistry());
runner.addTest(registry.makeTest());
bool wasSucessful;
try {
wasSucessful = runner.run("",false);
}
catch(string& rFailure) {
cerr << "Caught a string exception from test suites.: \n";
cerr << rFailure << endl;
wasSucessful = false;
}
return !wasSucessful;
}
示例13: main
int main(int argc, char* argv[])
{
// Get the top level suite from the registry
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
// Add test
CppUnit::TextUi::TestRunner runner;
runner.addTest( suite );
// Change default outputter to a compiler error format outputter
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) );
// Run tests
bool wasSucessful = runner.run();
// while(1);
// Error code 1 if any tests failed
return wasSucessful ? 0 : 1;
}
示例14: main
int main(int argc, char **argv)
{
QApplication app(argc, argv, false);
// compilers always write file names into manifest in Utf8
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Utf8"));
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
init(argv);
Resources res(Constants::getResourcesFilePath());
CppUnit::TextUi::TestRunner runner;
runner.addTest( GeneratedScriptTest::suite() );
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
std::cerr ) );
runner.run();
}
示例15: main
int main()
{
#ifdef ANTIOCH_HAVE_CPPUNIT
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
// If the tests all succeed, report success
if (runner.run())
return 0;
// If any test fails report failure
return 1;
#else
// If we don't have CPPUnit, report we skipped
// 77 return code tells Automake we skipped this.
return 77;
#endif // ANTIOCH_HAVE_CPPUNIT
}