#include <testregistry.h>
Definition at line 19 of file testregistry.h.
Public Member Functions | |
void | registerTestFactory (const TestFactory *tf, const char *group) |
unsigned int | run (const char *group) const |
unsigned int | run () const |
Static Public Member Functions | |
static void | deleteInstance () |
static TestRegistry * | instance () |
void KDAB::UnitTest::TestRegistry::deleteInstance | ( | ) | [static] |
KDAB::UnitTest::TestRegistry * KDAB::UnitTest::TestRegistry::instance | ( | ) | [static] |
Definition at line 23 of file testregistry.cpp.
Referenced by KDAB::UnitTest::GenericFactory< T_Test >::GenericFactory(), and KDAB::UnitTest::Runner::run().
void KDAB::UnitTest::TestRegistry::registerTestFactory | ( | const TestFactory * | tf, | |
const char * | group | |||
) |
Definition at line 34 of file testregistry.cpp.
Referenced by KDAB::UnitTest::GenericFactory< T_Test >::GenericFactory().
unsigned int KDAB::UnitTest::TestRegistry::run | ( | const char * | group | ) | const |
runs only tests in group group
Definition at line 57 of file testregistry.cpp.
00057 { 00058 assert( group ); assert( *group ); 00059 unsigned int failed = 0; 00060 const std::map< std::string, std::vector<const TestFactory*> >::const_iterator g = mTests.find( group ); 00061 if ( g == mTests.end() ) { 00062 std::cerr << "ERROR: No such group \"" << group << "\"" << std::endl; 00063 return 1; 00064 } 00065 std::cerr << "===== GROUP \"" << g->first << "\" =========" << std::endl; 00066 for ( std::vector<const TestFactory*>::const_iterator it = g->second.begin() ; it != g->second.end() ; ++it ) { 00067 std::auto_ptr<Test> t( (*it)->create() ); 00068 assert( t.get() ); 00069 std::cerr << " === \"" << t->name() << "\" ===" << std::endl; 00070 t->run(); 00071 std::cerr << " Succeeded: " << t->succeeded() << "; failed: " << t->failed() << std::endl; 00072 failed += t->failed(); 00073 } 00074 return failed; 00075 }
unsigned int KDAB::UnitTest::TestRegistry::run | ( | ) | const |
runs all tests in all groups.
Definition at line 39 of file testregistry.cpp.
Referenced by KDAB::UnitTest::Runner::run().
00039 { 00040 unsigned int failed = 0; 00041 for ( std::map< std::string, std::vector<const TestFactory*> >::const_iterator g = mTests.begin() ; g != mTests.end() ; ++g ) { 00042 std::cerr << "===== GROUP \"" << g->first << "\" =========" << std::endl; 00043 for ( std::vector<const TestFactory*>::const_iterator it = g->second.begin() ; it != g->second.end() ; ++it ) { 00044 std::auto_ptr<Test> t( (*it)->create() ); 00045 assert( t.get() ); 00046 std::cerr << " === \"" << t->name() << "\" ===" << std::endl; 00047 t->run(); 00048 std::cerr << " Succeeded: " << std::setw( 4 ) << t->succeeded() 00049 << "; failed: " << std::setw( 4 ) << t->failed() << std::endl; 00050 failed += t->failed(); 00051 } 00052 } 00053 return failed; 00054 }