本文整理汇总了C++中cppunit::TestResultCollector::wasSuccessful方法的典型用法代码示例。如果您正苦于以下问题:C++ TestResultCollector::wasSuccessful方法的具体用法?C++ TestResultCollector::wasSuccessful怎么用?C++ TestResultCollector::wasSuccessful使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cppunit::TestResultCollector
的用法示例。
在下文中一共展示了TestResultCollector::wasSuccessful方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例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;
}
示例3: 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::BriefTestProgressListener progress;
controller.addListener( &progress );
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
runner.run( controller, "" );
// Resultate im Compiler-Format ausgeben
CppUnit::CompilerOutputter compileroutputter( &result, std::cerr );
compileroutputter.write();
// Rueckmeldung, ob Tests erfolgreich waren
return ( result.wasSuccessful() ? 0 : -1 );
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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();
}
示例8: 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 );
TestRunner runner;
TestFactoryRegistry & registry = TestFactoryRegistry::getRegistry();
// run all tests if none specified on command line
Test * test_to_run = registry.makeTest();
if (argc > 1)
test_to_run = test_to_run->findTest(argv[1]);
runner.addTest( test_to_run );
// runner.run(controller);
try
{
std::cout << "Running tests" /*<< testPath*/ << endl;;
// runner.run( controller, testPath );
runner.run(controller);
// std::cerr << std::endl;
// Print test in a compiler compatible format.
CppUnit::CompilerOutputter outputter( &result, std::cerr );
outputter.write();
}
catch ( std::invalid_argument &e ) // Test path not resolved
{
std::cerr << std::endl
<< "ERROR: " << e.what()
<< std::endl;
return 0;
}
// result.runTest();
// results.printResults();
// runner.prin();
return result.wasSuccessful() ? 0 : 1;
}
示例9: 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;
}
}
示例10: main
int main (int argc, char *argv[])
{
// set up logger
//log4cxx::BasicConfigurator::configure();
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
if (argc == 1)
registry.addRegistry("All");
else
{
// run just the specified tests
for (int i=1; i<argc; i++)
registry.addRegistry(argv[i]);
}
CppUnit::TextUi::TestRunner runner;
runner.addTest(registry.makeTest());
// Errors have line numbers
runner.setOutputter(
CppUnit::CompilerOutputter::defaultOutputter(
&runner.result(),
std::cerr ) );
CppUnit::TestResult controller;
CppUnit::TestResultCollector result;
controller.addListener(&result);
// register listener for per-test progress output
// verbose, per-test output: test : OK
CppUnit::BriefTestProgressListener progress;
controller.addListener (&progress);
runner.run(controller);
// output stderr summary report
CppUnit::TextOutputter compilerOutputter(&result, std::cerr);
compilerOutputter.write();
// output xml report
std::ofstream strm("result.xml");
CppUnit::XmlOutputter xmlOutputter(&result, strm);
xmlOutputter.write();
return result.wasSuccessful() ? 0 : 1;
}
示例11: 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;
}
示例12: 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;
}
示例13: main
int main (int argc , char** argv)
{
std::ofstream xml("./cppUnit_output.xml",ios::app);
CppUnit::TestResult controller;
CppUnit::TestResultCollector result;
controller.addListener( &result );
TestRunner runner;
runner.addTest(Manipulation_test::suite());
runner.run(controller);
CppUnit::XmlOutputter outputter( &result, xml );
CppUnit::TextOutputter outputter2( &result, std::cerr );
outputter.write();
outputter2.write();
return result.wasSuccessful() ? 0 : 1 ;
}
示例14: 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;
}
示例15: main
int main(int argc, char* argv[])
{
CppUnit::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry = 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;
}