CppUnit project page | FAQ |
Registry for TestFactory.Notes that the registry DON'T assumes lifetime control for any registered tests anymore. More...
#include <TestFactoryRegistry.h>
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). | |
Public Member Functions inherited from TestFactory | |
virtual | ~TestFactory () |
Static Public Member Functions | |
static TestFactoryRegistry & | getRegistry (const std::string &name="All Tests") |
Returns a named registry. | |
static 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 |
Registry for TestFactory.
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().
Example 2: retreiving a suite that contains all the test registered with CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ..., "Math" ).
Example 3: creating a test suite hierarchy composed of unnamed registration and named registration:
The same result can be obtained with:
Since a TestFactoryRegistry is a TestFactory, the named registries can be registered in the unnamed registry, creating the hierarchy links.
|
private |
TestFactoryRegistry::TestFactoryRegistry | ( | std::string | name | ) |
Constructs the registry with the specified name.
name | Name of the registry. It is the name of TestSuite returned by makeTest(). |
|
virtual |
Destructor.
|
private |
void TestFactoryRegistry::addRegistry | ( | const std::string & | name | ) |
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:
name | Name of the registry to add. |
void TestFactoryRegistry::addTestToSuite | ( | TestSuite * | suite | ) |
Adds the registered tests to the specified suite.
suite | Suite the tests are added to. |
|
static |
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.
name | Name of the registry to return. |
|
static |
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.
true
if the specified registry has not been destroyed, otherwise returns false
.
|
virtual |
Returns a new TestSuite that contains the registered test.
Implements TestFactory.
|
private |
void TestFactoryRegistry::registerFactory | ( | TestFactory * | factory | ) |
Adds the specified TestFactory to the registry.
factory | Factory to register. |
void TestFactoryRegistry::registerFactory | ( | const std::string & | name, |
TestFactory * | factory | ||
) |
Adds the specified TestFactory with a specific name (DEPRECATED).
name | Name associated to the factory. |
factory | Factory to register. |
void TestFactoryRegistry::unregisterFactory | ( | TestFactory * | factory | ) |
Removes the specified TestFactory from the registry.
The specified factory is not destroyed.
factory | Factory to remove from the registry. |
|
private |
|
private |
Send comments to: CppUnit Developers |