| CppUnit project page | FAQ | CppUnit home page |
#include <TestFactoryRegistry.h>
Inheritance diagram for CppUnit::TestFactoryRegistry:

Public Methods | |
| TestFactoryRegistry (std::string name="All Tests") | |
| Constructs the registry with the specified name. More... | |
| virtual | ~TestFactoryRegistry () |
| Destructor. More... | |
| virtual Test * | makeTest () |
| Returns a new TestSuite that contains the registered test. More... | |
| void | addTestToSuite (TestSuite *suite) |
| Adds the registered tests to the specified suite. More... | |
| void | registerFactory (const std::string &name, TestFactory *factory) |
| Adds the specified TestFactory with a specific name (DEPRECATED). More... | |
| void | registerFactory (TestFactory *factory) |
| Adds the specified TestFactory to the registry. More... | |
Static Public Methods | |
| TestFactoryRegistry & | getRegistry () |
| Returns unnamed the registry. More... | |
| TestFactoryRegistry & | getRegistry (const std::string &name) |
| Returns a named registry. More... | |
Private Types | |
| typedef std::map< std::string, TestFactory * > | Factories |
Private Methods | |
| TestFactoryRegistry (const TestFactoryRegistry ©) | |
| void | operator= (const TestFactoryRegistry ©) |
Private Attributes | |
| Factories | m_factories |
| std::string | m_name |
Notes that the registry assumes lifetime control for any registered test.
To register tests, use the macros:
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); CppUnit::TestSuite *suite = registry.makeTest();
Example 2: retreiving a suite that contains all the test registered with CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ..., "Math" ).
CppUnit::TestFactoryRegistry &mathRegistry = CppUnit::TestFactoryRegistry::getRegistry( "Math" ); CppUnit::TestSuite *mathSuite = mathRegistry.makeTest();
Example 3: creating a test suite hierarchy composed of unnamed registration and named registration:
CppUnit::TestSuite *rootSuite = new CppUnit::TestSuite( "All tests" ); rootSuite->addTest( CppUnit::TestFactoryRegistry::getRegistry( "Graph" ).makeTest() ); rootSuite->addTest( CppUnit::TestFactoryRegistry::getRegistry( "Math" ).makeTest() ); CppUnit::TestFactoryRegistry::getRegistry().addTestToSuite( rootSuite );
The same result can be obtained with:
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); registry.registerFactory( CppUnit::TestFactoryRegistry::getRegistry( "Graph" ) ); registry.registerFactory( CppUnit::TestFactoryRegistry::getRegistry( "Math" ) ); CppUnit::TestSuite *suite = registry.makeTest();
Since a TestFactoryRegistry is a TestFactory, the named registries can be registered in the unnamed registry, creating the hierarchy links.
|
|
|
|
|
Constructs the registry with the specified name.
|
|
|
Destructor.
|
|
|
|
|
|
Adds the registered tests to the specified suite.
|
|
|
Returns a named registry. TestSuite registered using CPPUNIT_TEST_SUITE_NAMED_REGISTRATION() are registered in the registry of the same name.
|
|
|
Returns unnamed the registry. TestSuite registered using CPPUNIT_TEST_SUITE_REGISTRATION() are registered in this registry.
|
|
|
Returns a new TestSuite that contains the registered test.
Implements CppUnit::TestFactory. |
|
|
|
|
|
Adds the specified TestFactory to the registry.
|
|
||||||||||||
|
Adds the specified TestFactory with a specific name (DEPRECATED).
|
|
|
|
|
|
|
|
|
hosts this site. |
Send comments to: CppUnit Developers |