本文整理汇总了C++中cppunit::textui::TestRunner::result方法的典型用法代码示例。如果您正苦于以下问题:C++ TestRunner::result方法的具体用法?C++ TestRunner::result怎么用?C++ TestRunner::result使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cppunit::textui::TestRunner
的用法示例。
在下文中一共展示了TestRunner::result方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// Execute and run unit test
int main(int argc, char** argv)
{
CppUnit::TextUi::TestRunner runnerStdcerr;
runnerStdcerr.addTest(testMatchRegEx::suite());
runnerStdcerr.setOutputter(new CppUnit::CompilerOutputter( &runnerStdcerr.result(), cerr ));
runnerStdcerr.run();
return runnerStdcerr.result().testFailuresTotal();
}
示例2: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
bool wasSuccessful = false;
try
{
CppUnit::TextUi::TestRunner runner;
runner.setOutputter( new CppUnit::CompilerOutputter(&runner.result(), std::cerr));
/*CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry("BlackLagoonTestSuite");
runner.addTest(registry.makeTest());
wasSuccessful = runner.run("", false);*/
CppUnit::TestFactoryRegistry ®istry1 = CppUnit::TestFactoryRegistry::getRegistry("HighScoreComponentTestSuite");
CppUnit::TestFactoryRegistry ®istry2 = CppUnit::TestFactoryRegistry::getRegistry("PlayerTestSuite");
CppUnit::TestFactoryRegistry ®istry3 = CppUnit::TestFactoryRegistry::getRegistry("GameObjectTestSuite");
runner.addTest(registry1.makeTest());
runner.addTest(registry2.makeTest());
runner.addTest(registry3.makeTest());
wasSuccessful = runner.run("", false);
}
catch(const std::exception& e)
{
std::cerr << e.what() << std::endl;
wasSuccessful = false;
}
return (wasSuccessful == true) ? 0 : 1;
}
示例3: 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
// uncomment the following line if you need a compiler outputter.
runner.setOutputter(new CppUnit::CompilerOutputter( &runner.result(),
std::cout ) );
// Change the default outputter to a xml error format outputter
// uncomment the following line if you need a xml outputter.
//runner.setOutputter( new CppUnit::XmlOutputter( &runner.result(),
// std::cerr ) );
/// Run the tests.
// bool wasSuccessful = runner.run();
// If you want to avoid the CppUnit typical output change the line above
// by the following one:
bool wasSuccessful = runner.run("",false,true,false);
// Return error code 1 if the one of test failed.
// Uncomment the next line if you want to integrate CppUnit with Oval
if(!wasSuccessful) std::cerr <<"Error: CppUnit Failures"<<std::endl;
std::cout <<"[OVAL] Cppunit-result ="<<!wasSuccessful<<std::endl;
return wasSuccessful ? 0 : 1;
}
示例4:
int
main( int argc, char* argv[] )
{
ProjetUnivers::Kernel::Parameters::load("sound.config") ;
ProjetUnivers::Kernel::Log::init() ;
// if command line contains "-selftest" then this is the post build check
// => the output must be in the compiler error format.
bool selfTest = (argc > 1) &&
(std::string("-selftest") == argv[1]);
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
if ( selfTest )
{ // Change the default outputter to a compiler error format outputter
// The test runner owns the new outputter.
runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(
&runner.result(),
std::cerr ) );
}
// Run the test.
bool wasSucessful = runner.run( "" );
ProjetUnivers::Kernel::Log::close() ;
// Return error code 1 if the one of test failed.
return wasSucessful ? 0 : 1;
}
示例5: main
int main( int argc, char ** argv ) {
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
ofstream out;
if ( argc == 2 ) {
out.open( argv[ 1 ] );
}
runner.setOutputter(
new CppUnit::XmlOutputter(
&runner.result(),
( out.is_open() ? out : std::cerr )
)
);
// Run the tests.
bool wasSucessful = runner.run();
if ( out.is_open() ) {
out.close();
}
// Return error code 1 if the one of test failed.
return wasSucessful ? 0 : 1;
}
示例6: main
int main(int argc, const char* argv[]){
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
CppUnit::TextUi::TestRunner runner;
#ifdef DATA_FILENAME
const char* path = TOP_SRCDIR "/" DATA_FILENAME;
FILE* fp = fopen(path, "r");
if ( !fp ){
fprintf(stderr, "failed to read `%s'\n", path);
return 1;
}
/* read the test packet */
int bytes;
const int expected = DATA_SIZE;
if ( (bytes=fread(data, 1, sizeof(data), fp)) < expected ){
fprintf(stderr, "failed to read `%s' (data truncated, read %d bytes, expected %d)\n", path, bytes, expected);
return 1;
}
fclose(fp);
#endif
runner.addTest(suite);
runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr));
return runner.run() ? 0 : 1;
}
示例7: outputFile
int
main( int argc, char* argv[] )
{
ProjetUnivers::Kernel::Parameters::load("physic.config") ;
ProjetUnivers::Kernel::Log::init() ;
// if command line contains "-selftest" then this is the post build check
// => the output must be in the compiler error format.
bool selfTest = (argc > 1) &&
(std::string("-selftest") == argv[1]);
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
// Define the file that will store the XML output.
std::ofstream outputFile("tests_physic.xml");
CppUnit::MultiOutputter* outputter = new CppUnit::MultiOutputter() ;
outputter->add(new CppUnit::CompilerOutputter(&runner.result(),std::cerr)) ;
outputter->add(new ProjetUnivers::Kernel::XmlOutputter(&runner,outputFile)) ;
runner.setOutputter(outputter);
// Run the test.
bool wasSucessful = runner.run( "" );
ProjetUnivers::Kernel::Log::close() ;
// Return error code 1 if the one of test failed.
return wasSucessful ? 0 : 1;
}
示例8: executer
////////////////////////////////////////////////////////////////////////
///
/// @fn bool BancTests::executer()
///
/// Cette fonction exécute l'ensemble des tests unitaires définis.
/// La sortie de l'exécution des tests se fait dans la console standard
/// d'erreurs 'cerr'. Cette fonction ajuste également le format de
/// sortie pour correspondre à celui de Visual Studio afin d'intégrer
/// l'exécution des tests au processus de compilation ("Post Build Event").
///
/// @return true si l'exécution de tous les tests a réussi, sinon false.
///
////////////////////////////////////////////////////////////////////////
bool BancTests::executer()
{
// Obtenir la suite de tests à haut niveau
CppUnit::Test *suite{ CppUnit::TestFactoryRegistry::getRegistry().makeTest() };
// Obtient un environnement d'exécution de tests qui imprime les résultats
// dans une console (cout, cerr, fichier, etc.) et ajoute la suite de tests
// de base à l'environnement.
// (Notez qu'il est aussi possible d'obtenir un environnement qui affiche
// les résultats des tests au sein d'une interface graphique QT ou MFC.
// Consultez la documentation cppunit pour plus d'informations)
CppUnit::TextUi::TestRunner runner;
runner.addTest(suite);
// Indique que nous souhaitons formatter la sortie selon un format qui
// s'apparente à la sortie d'un compilateur (MSVC++), et que nous
// souhaitons que la sortie soit réalisée dans le canal standard cerr.
// Cela permettra à Visual Studio d'interpréter la sortie de cppunit,
// d'indiquer les erreurs trouvées par les tests et leur numéro de ligne
// en tant qu'erreurs survenant au niveau du processus de compilation.
runner.setOutputter(new CppUnit::CompilerOutputter{ &runner.result(),
std::cerr });
// Exécuter les tests
return runner.run();
}
示例9: outputFile
int
main( int argc, char* argv[] )
{
ProjetUnivers::Kernel::Parameters::load("kernel.config") ;
ProjetUnivers::Kernel::Log::init() ;
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest(registry.makeTest());
// Define the file that will store the XML output.
std::ofstream outputFile("tests_kernel_automatic_registration.xml");
CppUnit::MultiOutputter* outputter = new CppUnit::MultiOutputter() ;
outputter->add(new CppUnit::CompilerOutputter(&runner.result(),std::cerr)) ;
outputter->add(new ProjetUnivers::Kernel::XmlOutputter(&runner,outputFile)) ;
runner.setOutputter(outputter);
// Run the test.
bool wasSucessful = runner.run( "" );
ProjetUnivers::Kernel::Log::close() ;
// Return error code 1 if the one of test failed.
return wasSucessful ? 0 : 1;
}
示例10: main
int main()
{
CppUnit::TextUi::TestRunner runner;
// First add the tests from the named registries in the right order
// To add/remove/modify a registry name, or to change its sequence
// number, edit RegistryName.cpp
for (std::vector<std::string>::const_iterator name = getRegistryNameList().begin();
getRegistryNameList().end() != name; ++name)
{
CppUnit::Test *namedSuite = CppUnit::TestFactoryRegistry::getRegistry(*name).makeTest();
runner.addTest(namedSuite);
}
// Add the top level (unnamed) suite from the list of tests to run
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
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 wasSuccessful = runner.run();
// Return error code 1 if the one of test failed.
return wasSuccessful ? 0 : 1;
}
示例11: main
int main( int, char** argv)
{
CppUnit::TextUi::TestRunner runner;
runner.addTest( AddressTableTest::suite() );
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
std::cerr ) );
runner.run();
return 0;
}
示例12: main
int main(int argc, char* argv[])
{
CppUnit::TextUi::TestRunner runner;
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
CppUnit::Outputter* outputter =
new CppUnit::TextOutputter(&runner.result(), std::cout);
runner.setOutputter(outputter);
bool retcode = runner.run();
return !retcode;
}
示例13: main
int main(int argc, const 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 ));
return runner.run() ? 0 : 1;
}
示例14: main
int main(void)
{
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry("alltest");
ProgressListener listener;
runner.addTest(registry.makeTest());
runner.eventManager().addListener(&listener);
runner.run("", false, true, true);
return runner.result().testFailuresTotal() ? 1 : 0;
}
示例15: main
int main(int argc, char* argv[])
{
QCoreApplication a(argc, argv);
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
CppUnit::TextUi::TestRunner runner;
runner.addTest( registry.makeTest() );
if (argc >= 2 && !strcmp(argv[1],"--xml")) {
runner.setOutputter(new CppUnit::XmlOutputter(&runner.result(), std::cout));
}
return (runner.run("") ? 0 : 1);
}