The class TestResultCollector (see Figure C-27) collects test results that it receives from a TestResult via the TestListener interface. The results consist of the Test objects run and any failures or errors produced.

A TestResultCollector is a SynchronizedObject . Its operations are mutex-protected and thread-safe.

TestResultCollector belongs to the namespace CppUnit . It is declared in TestResultCollector.h and implemented in TestResultCollector.cpp .

Figure C-27. The class TestResultCollector


 class TestResultCollector : public TestSucessListener 


TestResultCollector(SynchronizationObject *syncObject = 0)

A constructor. If a SynchronizationObject is not provided, a new one is created.

virtual ~TestResultCollector( )

A destructor.

Public Methods

void addFailure(const TestFailure &failure)

A method that informs TestResultCollector of a TestFailure .

virtual const TestFailures& failures( ) const

Returns m_failures , the TestFailure objects collected by this TestResultCollector .

virtual void reset( )

Clears the collected results.

virtual int runTests( ) const

Returns the number of Test objects run.

void startTest(Test *test)

A method that informs TestResultCollector that test is about to be run.

virtual int testErrors( ) const

Returns the number of test errors collected.

virtual int testFailures( ) const

Returns the number of test failures collected.

virtual int testFailuresTotal( ) const

Returns the total number of test failures and errors collected.

virtual const Tests &tests( ) const

Returns m_tests , the Test objects collected by this TestResultCollector .

Protected/Private Methods

TestResultCollector(const TestResultCollector &other)

A copy constructor declared private to prevent its use.

TestResultCollector& operator=(const TestResultCollector &other)

A copy operator declared private to prevent its use.


typedef deque<TestFailure *> TestFailures

Defines the type TestFailures as a deque of TestFailure objects ( public ).

typedef deque<Test *> Tests

Defines the type Tests as a deque of Test objects ( public ).

TestFailures m_failures

The collected failures ( protected ).

int m_testErrors

The number of errors ( protected ).

Tests m_tests

The collected Test objects ( protected ).

Unit Test Frameworks
Unit Test Frameworks
ISBN: 0596006896
EAN: 2147483647
Year: 2006
Pages: 146
Authors: Paul Hamill

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net