#include <Pt/Unit/TestSuite.h>
Protocol and data driven testing. More...
Inherits Test, and TestFixture.
Public Member Functions | |
TestSuite (const std::string &name, TestProtocol &protocol=TestSuite::defaultProtocol) | |
Construct by name and protocol. More... | |
~TestSuite () | |
Destructor. | |
void | attachReporter (Reporter &r) |
Add reporter for test events. | |
void | detachReporter (Reporter &r) |
Removes a reporter. | |
const std::string & | name () const |
Returns the name of the test. | |
Test * | parent () |
Returns the parent test. | |
const Test * | parent () const |
Returns the parent test. | |
void | reportAssertion (const TestContext &ctx, const Assertion &ass) |
Assertion notification. More... | |
void | reportError (const TestContext &ctx) |
Error notification. More... | |
void | reportException (const TestContext &ctx, const std::exception &ex) |
Exception notification. More... | |
void | reportFinish (const TestContext &ctx) |
Finished notification. More... | |
void | reportMessage (const std::string &msg) |
Message notification. More... | |
void | reportStart (const TestContext &ctx) |
Reports the start of a test. | |
void | reportSuccess (const TestContext &ctx) |
Success notification. More... | |
virtual void | run () |
Runs the test suite. More... | |
void | runAll () |
Runs all tests. | |
void | runTest (const std::string &name, const SerializationInfo *args=0, std::size_t argCount=0) |
Runs a registered test. More... | |
void | setParent (Test *test) |
Sets the parent test. | |
void | setProtocol (TestProtocol *protocol) |
Sets the protocol. | |
virtual void | setUp () |
Set up conText before running a test. More... | |
virtual void | tearDown () |
Clean up after the test run. More... | |
The TestSuite is used to implement protocol and data driven tests. It inherits its ability to register methods and properties from Reflectable. The implementor is supposed to write and register the required test methods on construction.
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.
|
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. |
|
virtual |
This function is called before each registered tester function is invoked. It is meant to initialize any required resources.
Reimplemented from TestFixture.
|
virtual |
This function is called after each registered tester function is invoked. It is meant to remove any resources previously initialized in TestSuite::setUp.
Reimplemented from TestFixture.
|
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 , |
||
std::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 |
argCount | Number of arguments |
|
inherited |
This signal is sent when the test finished. It does not indicate that the test was successful.
|
inherited |
This signal is sent when the test was successful.
|
inherited |
This signal is sent when a assertion failed.
|
inherited |
This signal is sent when a regular std::exception occured.
|
inherited |
This signal is sent when an unknown error occured.
|
inherited |
This signal can be sent to report informational messages.