CppUnit project page | FAQ |
Manages TestListener.A single instance of this class is used when running the test. It is usually created by the test runner (TestRunner). More...
#include <TestResult.h>
Public Member Functions | |
TestResult (SynchronizationObject *syncObject=0) | |
Construct a TestResult. | |
virtual | ~TestResult () |
Destroys a test result. | |
virtual void | addListener (TestListener *listener) |
virtual void | removeListener (TestListener *listener) |
virtual void | reset () |
Resets the stop flag. | |
virtual void | stop () |
Stop testing. | |
virtual bool | shouldStop () const |
Returns whether testing should be stopped. | |
virtual void | startTest (Test *test) |
Informs TestListener that a test will be started. | |
virtual void | addError (Test *test, Exception *e) |
Adds an error to the list of errors. The passed in exception caused the error. | |
virtual void | addFailure (Test *test, Exception *e) |
Adds a failure to the list of failures. The passed in exception caused the failure. | |
virtual void | endTest (Test *test) |
Informs TestListener that a test was completed. | |
virtual void | startSuite (Test *test) |
Informs TestListener that a test suite will be started. | |
virtual void | endSuite (Test *test) |
Informs TestListener that a test suite was completed. | |
virtual void | runTest (Test *test) |
Run the specified test. | |
virtual bool | protect (const Functor &functor, Test *test, const std::string &shortDescription=std::string("")) |
Protects a call to the specified functor. | |
virtual void | pushProtector (Protector *protector) |
Adds the specified protector to the protector chain. | |
virtual void | popProtector () |
Removes the last protector from the protector chain. |
Protected Types | |
typedef CppUnitDeque < TestListener * > | TestListeners |
Protected Member Functions | |
void | addFailure (const TestFailure &failure) |
Called to add a failure to the list of failures. | |
virtual void | startTestRun (Test *test) |
virtual void | endTestRun (Test *test) |
Protected Member Functions inherited from SynchronizedObject | |
SynchronizedObject (SynchronizationObject *syncObject=0) | |
virtual | ~SynchronizedObject () |
Destructor. | |
virtual void | setSynchronizationObject (SynchronizationObject *syncObject) |
Accept a new synchronization object for protection of this instance TestResult assumes ownership of the object. |
Protected Attributes | |
TestListeners | m_listeners |
ProtectorChain * | m_protectorChain |
bool | m_stop |
Private Member Functions | |
TestResult (const TestResult &other) | |
TestResult & | operator= (const TestResult &other) |
Manages TestListener.
A single instance of this class is used when running the test. It is usually created by the test runner (TestRunner).
This class shouldn't have to be inherited from. Use a TestListener or one of its subclasses to be informed of the ongoing tests. Use a Outputter to receive a test summary once it has finished
TestResult supplies a template method 'setSynchronizationObject()' so that subclasses can provide mutual exclusion in the face of multiple threads. This can be useful when tests execute in one thread and they fill a subclass of TestResult which effects change in another thread. To have mutual exclusion, override setSynchronizationObject() and make sure that you create an instance of ExclusiveZone at the beginning of each method.
|
protected |
CPPUNIT_NS_BEGIN TestResult::TestResult | ( | SynchronizationObject * | syncObject = 0 | ) |
Construct a TestResult.
|
virtual |
Destroys a test result.
|
private |
Adds an error to the list of errors. The passed in exception caused the error.
Adds a failure to the list of failures. The passed in exception caused the failure.
|
protected |
Called to add a failure to the list of failures.
Reimplemented in TextTestResult.
|
virtual |
|
virtual |
Informs TestListener that a test suite was completed.
|
virtual |
Informs TestListener that a test was completed.
|
protectedvirtual |
|
private |
|
virtual |
Removes the last protector from the protector chain.
|
virtual |
Protects a call to the specified functor.
See Protector to understand how protector works. A default protector is always present. It captures CppUnit::Exception, std::exception and any other exceptions, retrieving as much as possible information about the exception as possible.
Additional Protector can be added to the chain to support other exception types using pushProtector() and popProtector().
|
virtual |
Adds the specified protector to the protector chain.
|
virtual |
|
virtual |
Resets the stop flag.
|
virtual |
Run the specified test.
Calls startTestRun(), test->run(this), and finally endTestRun().
|
virtual |
Returns whether testing should be stopped.
|
virtual |
Informs TestListener that a test suite will be started.
|
virtual |
Informs TestListener that a test will be started.
Reimplemented in TextTestResult.
|
protectedvirtual |
|
virtual |
Stop testing.
|
protected |
|
protected |
|
protected |
Send comments to: CppUnit Developers |