#include <Pt/Unit/TestCase.h>
Single test with setup and teardown.
More...
Inherits Test, and TestFixture.
|
| | TestCase (const std::string &name) |
| | Construct by name.
|
|
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.
|
| virtual void | setUp () |
| | Set up conText before running a test.
|
| virtual void | tearDown () |
| | Clean up after the test run.
|
|
const std::string & | name () const |
| | Returns the name of the test.
|
|
void | reportStart (const TestContext &ctx) |
| | Reports the start of a test.
|
| void | reportFinish (const TestContext &ctx) |
| | Finished notification.
|
| void | reportSuccess (const TestContext &ctx) |
| | Success notification.
|
| void | reportAssertion (const TestContext &ctx, const Assertion &ass) |
| | Assertion notification.
|
| void | reportException (const TestContext &ctx, const std::exception &ex) |
| | Exception notification.
|
| void | reportError (const TestContext &ctx) |
| | Error notification.
|
| void | reportMessage (const std::string &msg) |
| | Message notification.
|
|
void | setParent (Test *test) |
| | Sets the parent test.
|
|
Test * | parent () |
| | Returns the parent test.
|
|
const Test * | parent () const |
| | Returns the parent test.
|
|
void | attachReporter (Reporter &r) |
| | Add reporter for test events.
|
|
void | detachReporter (Reporter &r) |
| | Removes a reporter.
|
|
|
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'.
{
public:
MyTest()
{}
{
}
{
}
{
}
};
static Pt::Unit::RegisterTest<MyTest> _reg;
Single test with setup and teardown.
Definition TestCase.h:82
TestCase(const std::string &name)
Construct by name.
virtual void test()=0
Implements the actual test procedure When the test is run, this method will be called after setUp and...
virtual void setUp()
Set up conText before running a test.
virtual void tearDown()
Clean up after the test run.
Protocol and data driven unit testing framework.
Core module.
Definition Allocator.h:33
Once the test is written it can be registered to an application by using the RegisterTest class template.
◆ TestCase()
| TestCase |
( |
const std::string & | name | ) |
|
Constructs a TestCase with the passed name.
- Parameters
-
◆ setUp()
This function is called before each registered tester function is invoked. It is meant to initialize any required resources.
Reimplemented from TestFixture.
◆ tearDown()
| 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 TestCase::setUp.
Reimplemented from TestFixture.
◆ reportFinish()
This signal is sent when the test finished. It does not indicate that the test was successful.
◆ reportSuccess()
This signal is sent when the test was successful.
◆ reportAssertion()
This signal is sent when a assertion failed.
◆ reportException()
template<class C>
| void reportException |
( |
const TestContext & | ctx, |
|
|
const std::exception & | ex ) |
|
inherited |
This signal is sent when a regular std::exception occured.
◆ reportError()
This signal is sent when an unknown error occured.
◆ reportMessage()
template<class C>
| void reportMessage |
( |
const std::string & | msg | ) |
|
|
inherited |
This signal can be sent to report informational messages.