CppUnit project page | FAQ | CppUnit home page |
#include <TestFactoryRegistry.h>
Inheritance diagram for TestFactoryRegistry:
Public Member Functions | |
TestFactoryRegistry (std::string name) | |
Constructs the registry with the specified name. | |
virtual | ~TestFactoryRegistry () |
Destructor. | |
virtual Test * | makeTest () |
Returns a new TestSuite that contains the registered test. | |
void | addTestToSuite (TestSuite *suite) |
Adds the registered tests to the specified suite. | |
void | registerFactory (TestFactory *factory) |
Adds the specified TestFactory to the registry. | |
void | unregisterFactory (TestFactory *factory) |
void | addRegistry (const std::string &name) |
void | registerFactory (const std::string &name, TestFactory *factory) |
Adds the specified TestFactory with a specific name (DEPRECATED). | |
Static Public Member Functions | |
TestFactoryRegistry & | getRegistry (const std::string &name="All Tests") |
Returns a named registry. | |
bool | isValid () |
Private Types | |
typedef CppUnitSet< TestFactory *, std::less< TestFactory * > > | Factories |
Private Member Functions | |
TestFactoryRegistry (const TestFactoryRegistry ©) | |
void | operator= (const TestFactoryRegistry ©) |
Private Attributes | |
Factories | m_factories |
std::string | m_name |
Notes that the registry DON'T assumes lifetime control for any registered tests anymore.
The default registry is the registry returned by getRegistry() with the default name parameter value.
To register tests, use the macros:
Example 1: retreiving a suite that contains all the test registered with CPPUNIT_TEST_SUITE_REGISTRATION().
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.addRegistry( "Graph" ); registry.addRegistry( "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.
CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_SUITE_NAMED_REGISTRATION
|
|
|
Constructs the registry with the specified name.
|
|
Destructor.
|
|
|
|
Adds a registry to the registry. Convenience method to help create test hierarchy. See TestFactoryRegistry detail for examples of use. Calling this method is equivalent to:
|
|
Adds the registered tests to the specified suite.
|
|
Returns a named registry. If the name is left to its default value, then the registry that is returned is the one used by CPPUNIT_TEST_SUITE_REGISTRATION(): the 'top' level registry.
|
|
Tests if the registry is valid. This method should be used when unregistering test factory on static variable destruction to ensure that the registry has not been already destroyed (in that case there is no need to unregister the test factory). You should not concern yourself with this method unless you are writing a class like AutoRegisterSuite.
|
|
Returns a new TestSuite that contains the registered test.
Implements TestFactory. |
|
|
|
Adds the specified TestFactory with a specific name (DEPRECATED).
|
|
Adds the specified TestFactory to the registry.
|
|
Removes the specified TestFactory from the registry. The specified factory is not destroyed.
|
|
|
|
|
hosts this site. |
Send comments to: CppUnit Developers |