KDAB::UnitTest::TestRegistry Class Reference

#include <testregistry.h>

Collaboration diagram for KDAB::UnitTest::TestRegistry:

Collaboration graph
[legend]

List of all members.


Detailed Description

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 TestRegistryinstance ()

Member Function Documentation

void KDAB::UnitTest::TestRegistry::deleteInstance (  )  [static]

Definition at line 30 of file testregistry.cpp.

Referenced by KDAB::UnitTest::Runner::~Runner().

00030                                               {
00031     delete mSelf; mSelf = 0;
00032 }

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().

00023                                                               {
00024     if ( !mSelf )
00025         mSelf = new TestRegistry;
00026     return mSelf;
00027 }

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().

00034                                                                                                {
00035     assert( tf );
00036     mTests[group].push_back( tf );
00037 }

unsigned int KDAB::UnitTest::TestRegistry::run ( const char *  group  )  const

runs only tests in group group

Returns:
the number of failed tests (if any)

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.

Returns:
the number of failed tests (if any)

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 }


The documentation for this class was generated from the following files:
Generated on Thu Mar 4 23:25:16 2010 for KD Chart 2 by  doxygen 1.5.4