#include <Pt/Unit/TestCase.h>
Single test with setup and teardown. More...
Inherits Test, and TestFixture.
Public Member Functions | |
TestCase (const std::string &name) | |
Construct by name. More... | |
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 When the test is run, 'setUp' will be called first, then 'test' and finally 'tearDown'. Signals inherited from Unit::Test are sent appropriatly. | |
void | setParent (Test *test) |
Sets the parent test. | |
virtual void | setUp () |
Set up conText before running a test. More... | |
virtual void | tearDown () |
Clean up after the test run. More... | |
Protected Member Functions | |
virtual void | test ()=0 |
Implements the actual test procedure When the test is run, this method will be called after setUp and before tearDown. | |
A TestCase can be used for simple tests that require a initialization and deinitialization of resources. The implementor is supposed to implement the abstract method 'test' and the methods 'setUp' and 'tearDown' for resource management. When the test is run, 'setUp' will be called first, then 'test' and finally 'tearDown'.
Once the test is written it can be registered to an application by using the RegisterTest class template.
TestCase | ( | const std::string & | name | ) |
Constructs a TestCase with the passed name.
name | Name of 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 TestCase::setUp.
Reimplemented from TestFixture.
|
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.