CPUnit 0.95 (beta)
The REAL C++ port of JUnit.
|
This class is where all tests are registered. More...
#include <cpunit_TestStore.hpp>
Public Member Functions | |
void | insert_set_up (Callable *su) |
Inserts a set-up method for the suite named in the passed Callable object. | |
void | insert_tear_down (Callable *td) |
Inserts a tear-down method for the suite named in the passed Callable object. | |
void | insert_test (Callable *test) |
Inserts a test method for the suite named in the passed Callable object. | |
std::vector< TestUnit > | get_test_units (const std::string &pattern) |
Returns a selection of tests in terms of TestUnits. | |
std::vector< RegInfo > | get_tests (const std::string &pattern) |
Returns a selection of tests in terms of RegInfos. | |
Static Public Member Functions | |
static TestStore & | get_instance () |
The singleton get-instance method. | |
static void | dispose () |
Static class member which deletes the singleton instance. | |
Private Member Functions | |
TestStore () | |
Initiates an empty TestStore. | |
~TestStore () | |
Destructor. | |
std::vector< std::string > | decompose_path (const std::string &path) const |
Decomposes scoped name into a vector of path elements. | |
TestTreeNode * | find_node (const std::string &path, const bool create_nonexisting) |
Locates the TestTreeNode matching the given path, possibly creating the node if it does not already exist. | |
Private Attributes | |
std::auto_ptr< TestTreeNode > | root |
Static Private Attributes | |
static TestStore * | INSTANCE |
This class is where all tests are registered.
The class is implemented as a singleton, and provides methods for registration of tests and fixtures (set_up and tear_down), as well as query methods for obtaining subsets of the tests.
Definition at line 53 of file cpunit_TestStore.hpp.
cpunit::TestStore::TestStore | ( | ) | [private] |
Initiates an empty TestStore.
Definition at line 43 of file cpunit_TestStore.cpp.
cpunit::TestStore::~TestStore | ( | ) | [private] |
Destructor.
All registered tests are deleted when the tests store dies.
Definition at line 52 of file cpunit_TestStore.cpp.
std::vector< std::string > cpunit::TestStore::decompose_path | ( | const std::string & | path | ) | const [private] |
Decomposes scoped name into a vector of path elements.
E.g., passing "cpunit::info", will cause the resulting vector to contain the elements {"cpunit", "info"}.
path | A scoped path, using "::" as path delimiter. |
Definition at line 160 of file cpunit_TestStore.cpp.
void cpunit::TestStore::dispose | ( | ) | [static] |
Static class member which deletes the singleton instance.
It is important that the test framework does not leak any memory, as it will make it more difficult to detect memory leaks in the application under test.
Definition at line 63 of file cpunit_TestStore.cpp.
cpunit::TestTreeNode * cpunit::TestStore::find_node | ( | const std::string & | path, |
const bool | createIfNonExisting | ||
) | [private] |
Locates the TestTreeNode matching the given path, possibly creating the node if it does not already exist.
path | The C++ path to the desired TestTreeNode, using "::" as delimiter. |
createIfNonExisting | If true, the node will be created if it does not already exist. |
NULL
if it does not exist and createIfNonExisting is false. Definition at line 189 of file cpunit_TestStore.cpp.
cpunit::TestStore & cpunit::TestStore::get_instance | ( | ) | [static] |
The singleton get-instance method.
Definition at line 74 of file cpunit_TestStore.cpp.
std::vector< cpunit::TestUnit > cpunit::TestStore::get_test_units | ( | const std::string & | pattern | ) |
Returns a selection of tests in terms of TestUnits.
pattern | The glob pattern to match against. Passing "*" will return all registered tests. |
Definition at line 129 of file cpunit_TestStore.cpp.
std::vector< cpunit::RegInfo > cpunit::TestStore::get_tests | ( | const std::string & | pattern | ) |
Returns a selection of tests in terms of RegInfos.
pattern | The glob pattern to match against. Passing "*" will return all registered tests. |
Definition at line 143 of file cpunit_TestStore.cpp.
void cpunit::TestStore::insert_set_up | ( | Callable * | su | ) |
Inserts a set-up method for the suite named in the passed Callable object.
su | A Callable pointer to the set-up method to register. The test store takes over control of the Callable object. |
WrongSetupException | if a set-up method is already registered for the suite the set-up is to be registered for. |
Definition at line 89 of file cpunit_TestStore.cpp.
void cpunit::TestStore::insert_tear_down | ( | Callable * | td | ) |
Inserts a tear-down method for the suite named in the passed Callable object.
td | A Callable pointer to the tear-down method to register. The test store takes over control of the Callable object. |
WrongSetupException | if a tear-down method is already registered for the suite the tear-down is to be registered for. |
Definition at line 103 of file cpunit_TestStore.cpp.
void cpunit::TestStore::insert_test | ( | Callable * | test | ) |
Inserts a test method for the suite named in the passed Callable object.
test | A Callable pointer to the test method to register. The test store takes over control of the Callable object. |
WrongSetupException | if the test is already registered. |
Definition at line 116 of file cpunit_TestStore.cpp.
cpunit::TestStore * cpunit::TestStore::INSTANCE [static, private] |
Definition at line 54 of file cpunit_TestStore.hpp.
std::auto_ptr<TestTreeNode> cpunit::TestStore::root [private] |
Definition at line 58 of file cpunit_TestStore.hpp.