Wednesday, November 11, 2009

TestResult











 < Day Day Up > 





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.





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 *listener)





Adds a TestListener to this

TestResult.






virtual void endTest(Test *test)





A method that informs TestResult that

test has ended.






virtual void removeListener(TestListener *listener)





Removes a TestListener from this

TestResult.






virtual void reset( )





Sets m_stop to FALSE to prepare

for a new test run.






virtual bool shouldStop( ) const





Returns the value of m_stop.






virtual void startTest(Test *test)





A method that informs TestResult that

test is about to be run.






virtual void stop( )





Sets m_stop to TRUE to stop the

test run.











Protected/Private Methods






void addFailure(const TestFailure &failure)





A protected method that adds a

TestFailure and inform listeners.






TestResult(const TestResult &other)





A copy constructor declared private to prevent its

use.






TestResult& operator=(const TestResult &other)





A copy operator declared private to prevent its

use.











Attributes






typedef deque<TestListener *> TestListeners





Defines the type TestListeners as a

deque of TestListener objects

(protected).






TestListeners m_listeners





The test listeners (protected).






bool m_stop





If TRUE, the test run should stop

(protected).





















     < Day Day Up > 



    No comments: