Name

TestResult

Description

The class TestResult (see Figure C-26) receives test results from Test objects. Test results can be categorized as successes, failures, and errors. Normally, when multiple Test classes are run, a single TestResult is passed to the run( ) method of each Test.

A TestResult informs its observers of test progress and results using the TestListener interface. The TestListener subclass TestResultCollector normally is used to store the results. TestResult doesn’t store the results itself.

A TestResult is a SynchronizedObject. Its operations are mutex-protected and thread-safe, allowing Test and TestListener objects to run in separate threads.

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

The class TestResult
Figure C-26. The class TestResult

Declaration

class TestResult : protected SynchronizedObject

Constructors/Destructors

TestResult(SynchronizationObject *syncObject = 0)

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

virtual ~TestResult( )

A destructor.

Public Methods virtual void addError(Test *test, Exception *e)

A method that informs TestResult of a test error (an Exception not caused by a test assertion).

virtual void addFailure(Test *test, Exception *e)

A method that informs TestResult of a test failure (an Exception caused by a test assertion).

virtual void addListener(TestListener ...

Get Unit Test Frameworks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.