CppUnit project page FAQ CppUnit home page

Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

CppUnit::TestResult Class Reference

A TestResult collects the results of executing a test case. More...

#include <TestResult.h>

Inheritance diagram for CppUnit::TestResult:

Inheritance graph
[legend]
List of all members.

Public Methods

 TestResult ()
 Construct a TestResult. More...

virtual ~TestResult ()
 Destroys a test result. More...

virtual void addError (Test *test, Exception *e)
 Adds an error to the list of errors. More...

virtual void addFailure (Test *test, Exception *e)
 Adds a failure to the list of failures. More...

virtual void startTest (Test *test)
 Informs the result that a test will be started. More...

virtual void endTest (Test *test)
 Informs the result that a test was completed. More...

virtual int runTests ()
 Gets the number of run tests. More...

virtual int testErrors ()
 Gets the number of detected errors. More...

virtual int testFailures ()
 Gets the number of detected failures. More...

virtual bool wasSuccessful ()
 Returns whether the entire test was successful or not. More...

virtual bool shouldStop ()
 Returns whether testing should be stopped. More...

virtual void stop ()
 Stop testing. More...

virtual std::vector< TestFailure *> & errors ()
 Returns a vector of the errors. More...

virtual std::vector< TestFailure *> & failures ()
 Returns a vector of the failures. More...

virtual void addListener (TestListener *listener)
virtual void removeListener (TestListener *listener)

Protected Methods

virtual void setSynchronizationObject (SynchronizationObject *syncObject)
 Accept a new synchronization object for protection of this instance TestResult assumes ownership of the object. More...


Protected Attributes

std::vector< TestFailure *> m_errors
std::vector< TestFailure *> m_failures
std::vector< TestListener *> m_listeners
int m_runTests
bool m_stop
SynchronizationObjectm_syncObject

Private Methods

 TestResult (const TestResult &other)
TestResult & operator= (const TestResult &other)

Detailed Description

A TestResult collects the results of executing a test case.

It is an instance of the Collecting Parameter pattern.

The test framework distinguishes between failures and errors. A failure is anticipated and checked for with assertions. Errors are unanticipated problems signified by exceptions that are not generated by the framework.

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.

See also:
Test


Constructor & Destructor Documentation

CppUnit::TestResult::TestResult  
 

Construct a TestResult.

CppUnit::TestResult::~TestResult   [virtual]
 

Destroys a test result.

CppUnit::TestResult::TestResult const TestResult &   other [private]
 


Member Function Documentation

void CppUnit::TestResult::addError Test *   test,
Exception *   e
[virtual]
 

Adds an error to the list of errors.

The passed in exception caused the error

Reimplemented in CppUnit::TextTestResult.

void CppUnit::TestResult::addFailure Test *   test,
Exception *   e
[virtual]
 

Adds a failure to the list of failures.

The passed in exception caused the failure.

Reimplemented in CppUnit::TextTestResult.

void CppUnit::TestResult::addListener TestListener *   listener [virtual]
 

void CppUnit::TestResult::endTest Test *   test [virtual]
 

Informs the result that a test was completed.

std::vector< TestFailure *> & CppUnit::TestResult::errors   [virtual]
 

Returns a vector of the errors.

std::vector< TestFailure *> & CppUnit::TestResult::failures   [virtual]
 

Returns a vector of the failures.

TestResult& CppUnit::TestResult::operator= const TestResult &   other [private]
 

void CppUnit::TestResult::removeListener TestListener *   listener [virtual]
 

int CppUnit::TestResult::runTests   [virtual]
 

Gets the number of run tests.

void CppUnit::TestResult::setSynchronizationObject SynchronizationObject *   syncObject [protected, virtual]
 

Accept a new synchronization object for protection of this instance TestResult assumes ownership of the object.

bool CppUnit::TestResult::shouldStop   [virtual]
 

Returns whether testing should be stopped.

void CppUnit::TestResult::startTest Test *   test [virtual]
 

Informs the result that a test will be started.

Reimplemented in CppUnit::TextTestResult.

void CppUnit::TestResult::stop   [virtual]
 

Stop testing.

int CppUnit::TestResult::testErrors   [virtual]
 

Gets the number of detected errors.

int CppUnit::TestResult::testFailures   [virtual]
 

Gets the number of detected failures.

bool CppUnit::TestResult::wasSuccessful   [virtual]
 

Returns whether the entire test was successful or not.


Member Data Documentation

std::vector<TestFailure *> CppUnit::TestResult::m_errors [protected]
 

std::vector<TestFailure *> CppUnit::TestResult::m_failures [protected]
 

std::vector<TestListener *> CppUnit::TestResult::m_listeners [protected]
 

int CppUnit::TestResult::m_runTests [protected]
 

bool CppUnit::TestResult::m_stop [protected]
 

SynchronizationObject* CppUnit::TestResult::m_syncObject [protected]
 


The documentation for this class was generated from the following files:
SourceForge Logo hosts this site. Send comments to:
CppUnit Developers