#include <Pt/Unit/TestSuite.h>

Public Member Functions | |
| TestSuite (const std::string &name, TestProtocol &protocol=TestSuite::defaultProtocol) | |
| Construct by name and protocol. | |
| virtual void | setParameter (const std::string &name, const Pt::SerializationInfo &value) |
| TODO: rename setParameter. | |
| void | setProtocol (TestProtocol *protocol) |
| Sets the protocol. | |
| virtual void | setUp () |
| Set up conText before running a test. | |
| virtual void | tearDown () |
| Clean up after the test run. | |
| virtual void | run () |
| Runs the test suite. | |
| void | runTest (const std::string &name, const SerializationInfo *args=0, size_t argCount=0) |
| Runs a registered test. | |
| void | runAll () |
Static Public Attributes | |
| static TestProtocol | defaultProtocol |
Protected Member Functions | |
| template<class ParentT> | |
| void | registerMethod (const std::string &name, ParentT &parent, void(ParentT::*method)()) |
| template<class ParentT, typename A1> | |
| void | registerMethod (const std::string &name, ParentT &parent, void(ParentT::*method)(A1)) |
| template<class ParentT, typename A1, typename A2> | |
| void | registerMethod (const std::string &name, ParentT &parent, void(ParentT::*method)(A1, A2)) |
| template<class ParentT, typename A1, typename A2, typename A3> | |
| void | registerMethod (const std::string &name, ParentT &parent, void(ParentT::*method)(A1, A2, A3)) |
| template<class ParentT, typename A1, typename A2, typename A3, typename A4> | |
| void | registerMethod (const std::string &name, ParentT &parent, void(ParentT::*method)(A1, A2, A3, A4)) |
| template<class ParentT, typename A1, typename A2, typename A3, typename A4, typename A5> | |
| void | registerMethod (const std::string &name, ParentT &parent, void(ParentT::*method)(A1, A2, A3, A4, A5)) |
Classes | |
| class | Context |
class MyTest : public TestSuite { public: MyTest() : TestSuite("MyTest") { this->registerMethod("test1", *this, &MyTest::test1); } void test1(); };
Once the test is written it can be registered to an application by using the RegisterTest class template.
The default protocol will run each registered test method when the test is run. Before each test method setUp is called and tearDown after each test. The TestProtocol can be replaced with a customised one and reflection can be used to call any method multiple times with the required data.
| TestSuite | ( | const std::string & | name, | |
| TestProtocol & | protocol = TestSuite::defaultProtocol | |||
| ) | [explicit] |
Constructs a TestCase with the passed name and optionally a custom protocol. The protocol is not owned by the TestSuite, but can be owned by the derived class.
| name | Name of the test | |
| protocol | Protocol for the test. |
| void setProtocol | ( | TestProtocol * | protocol | ) |
| protocol | Protocol for the test |
| virtual void setUp | ( | ) | [virtual] |
This function is called before each registered tester function is invoked. It is meant to initialize any required resources.
| virtual void tearDown | ( | ) | [virtual] |
This function is called after each registered tester function is invoked. It is meant to remove any resources previously initialized in TestSuite::setUp.
| virtual void run | ( | ) | [virtual] |
The TestProtocol assosiated with the test will be executed. The default protocol will simply call all registered tests.
Implements Test.
| void runTest | ( | const std::string & | name, | |
| const SerializationInfo * | args = 0, |
|||
| size_t | argCount = 0 | |||
| ) |
A test method will be called by name and the given arguments are passe to it just like when the reflection API is used. The method 'setUp' will be called before, and the method tearDown after the test. Signals inherited from Unit::Test are sent appropriatly.
| name | Name of the method to be run | |
| args | Arguments to invoke the method |