CppUnit - The Unit Testing Library

CppUnit project page | FAQ

TestResultCollector Class Reference
Writing test result | Browsing collected test result

Collects test result. More...

`#include <TestResultCollector.h>`

Inheritance diagram for TestResultCollector:
[legend]
Collaboration diagram for TestResultCollector:
[legend]

## Public Types
typedef std::deque< TestFailure * > | TestFailures
typedef std::deque< Test * > | Tests

## Public Member Functions
| TestResultCollector (SynchronizationObject *syncObject=0)
virtual | ~TestResultCollector ()
| Destructor.
void | startTest (Test *test)
| Called when just before a TestCase is run.
void | addFailure (const TestFailure &failure)
| Called when a failure occurs while running a test.
virtual void | reset ()
virtual int | runTests () const
| Gets the number of run tests.
virtual int | testErrors () const
| Gets the number of detected errors (uncaught exception).
virtual int | testFailures () const
| Gets the number of detected failures (failed assertion).
virtual int | testFailuresTotal () const
| Gets the total number of detected failures.
virtual const TestFailures & | failures () const
| Returns a the list failures (random access collection).
virtual const Tests & | tests () const
Public Member Functions inherited from TestSuccessListener
| TestSuccessListener (SynchronizationObject *syncObject=0)
virtual | ~TestSuccessListener ()
| Destructor.
void | addFailure (const TestFailure &failure)
| Called when a failure occurs while running a test.
virtual bool | wasSuccessful () const
| Returns whether the entire test was successful or not.
Public Member Functions inherited from TestListener
virtual | ~TestListener ()
virtual void | endTest (Test *)
| Called just after a TestCase was run (even if a failure occured).
virtual void | startSuite (Test *)
| Called by a TestComposite just before running its child tests.
virtual void | endSuite (Test *)
| Called by a TestComposite after running its child tests.
virtual void | startTestRun (Test *, TestResult *)
| Called by a TestRunner before running the test.
virtual void | endTestRun (Test *, TestResult *)
| Called by a TestRunner after running the test.
Public Member Functions inherited from SynchronizedObject
| SynchronizedObject (SynchronizationObject *syncObject=0)
virtual | ~SynchronizedObject ()
| Destructor.

## Protected Member Functions
void | freeFailures ()
Protected Member Functions inherited from SynchronizedObject
virtual void | setSynchronizationObject (SynchronizationObject *syncObject)
| Accept a new synchronization object for protection of this instance TestResult assumes ownership of the object.

## Protected Attributes
Tests | m_tests
TestFailures | m_failures
int | m_testErrors
Protected Attributes inherited from SynchronizedObject
SynchronizationObject * | m_syncObject

## Private Member Functions
| TestResultCollector (const TestResultCollector &copy)
| Prevents the use of the copy constructor.
void | operator= (const TestResultCollector &copy)
| Prevents the use of the copy operator.

## Detailed Description

Collects test result.

A TestResultCollector is a TestListener which 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.

See also
  TestListener, TestFailure.

## Member Typedef Documentation

## ◆ TestFailures

typedef std::deque<TestFailure *> TestResultCollector::TestFailures

## ◆ Tests

typedef std::deque<Test *> TestResultCollector::Tests

## Constructor & Destructor Documentation

## ◆ TestResultCollector() [1/2]

CPPUNIT_NS_BEGIN TestResultCollector::TestResultCollector | ( | SynchronizationObject * | syncObject = 0 | ) |

Constructs a TestResultCollector object.

## ◆ ~TestResultCollector()

TestResultCollector::~TestResultCollector | ( |  | ) |
| virtual

Destructor.

## ◆ TestResultCollector() [2/2]

TestResultCollector::TestResultCollector | ( | const TestResultCollector & | copy | ) |
| private

Prevents the use of the copy constructor.

## Member Function Documentation

## ◆ addFailure()

void TestResultCollector::addFailure | ( | const TestFailure & | failure | ) |
| virtual

Called when a failure occurs while running a test.

See also
  TestFailure.

Warning
  failure is a temporary object that is destroyed after the method call. Use TestFailure::clone() to create a duplicate.

Reimplemented from TestListener.

Reimplemented in TextTestResult.

## ◆ failures()

const TestResultCollector::TestFailures & TestResultCollector::failures | ( |  | ) | const
| virtual

Returns a the list failures (random access collection).

## ◆ freeFailures()

void TestResultCollector::freeFailures | ( |  | ) |
| protected

## ◆ operator=()

void TestResultCollector::operator= | ( | const TestResultCollector & | copy | ) |
| private

Prevents the use of the copy operator.

## ◆ reset()

void TestResultCollector::reset | ( |  | ) |
| virtual

Reimplemented from TestSuccessListener.

## ◆ runTests()

int TestResultCollector::runTests | ( |  | ) | const
| virtual

Gets the number of run tests.

## ◆ startTest()

void TestResultCollector::startTest | ( | Test * | test | ) |
| virtual

Called when just before a TestCase is run.

Reimplemented from TestListener.

Reimplemented in TextTestResult.

## ◆ testErrors()

int TestResultCollector::testErrors | ( |  | ) | const
| virtual

Gets the number of detected errors (uncaught exception).

## ◆ testFailures()

int TestResultCollector::testFailures | ( |  | ) | const
| virtual

Gets the number of detected failures (failed assertion).

## ◆ testFailuresTotal()

int TestResultCollector::testFailuresTotal | ( |  | ) | const
| virtual

Gets the total number of detected failures.

## ◆ tests()

const TestResultCollector::Tests & TestResultCollector::tests | ( |  | ) | const
| virtual

## Member Data Documentation

## ◆ m_failures

TestFailures TestResultCollector::m_failures
| protected

## ◆ m_testErrors

int TestResultCollector::m_testErrors
| protected

## ◆ m_tests

Tests TestResultCollector::m_tests
| protected

The documentation for this class was generated from the following files:

- TestResultCollector.h
- TestResultCollector.cpp

| Send comments to: CppUnit Developers