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.
![]() |
Declaration
class TestResult : protected SynchronizedObject
Constructors/Destructors
-
TestResult(SynchronizationObject *syncObject = 0) A constructor. If a
SynchronizationObjectis not provided, a new one is created.-
virtual ~TestResult( ) A destructor.
-
Public Methodsvirtual void addError(Test *test, Exception *e) A method that informs
TestResultof a test error (anExceptionnot caused by a test assertion).-
virtual void addFailure(Test *test, Exception *e) A method that informs
TestResultof a test failure (anExceptioncaused by a test assertion).-
virtual void addListener(TestListener ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
