Re: [Cppunit-devel] output fix
Brought to you by:
blep
From: Steve M. R. <ste...@vi...> - 2001-05-24 15:02:13
|
On Wed, May 23, 2001 at 05:06:45PM -0400, Steve M. Robbins wrote: > There's a consistency bug in the TextTestResult output: normal results > give a ".", while errors and failures emit a newline after the "E" or "F". I realized later that this is inaccurate. For *every* test, a '.' is output. If the test succeeds, nothing further is emitted. If it fails or causes an error, then an 'E' or 'F' is also output (plus a newline until the patch is applied). One might prefer to have precisely ONE character emitted per test. Myself, I prefer the previous verbose style that printed the test names as they were executed. To that end, I have derived a new class from TestResult. If you wish to include this as an example or whatever, be my guest. -Steve P.S. Incidentally, I discovered that simple functions, like "TestResult::runTests()" that returns the number of tests run, are not declared "const". Is that an oversight, or does it have something to do with the synchronization baggage that TestResult carries? namespace CppUnit { class Exception; class Test; class VerboseTestResult : public TestResult { public: virtual void startTest (Test *test) { cerr << test->getName() << endl; TestResult::startTest( test ); } virtual void addError (Test *test, Exception *e) { cerr << " Error at " << e->fileName() << ":" << e->lineNumber() << ": " << e->what() << endl; TestResult::addError( test, e ); } virtual void addFailure (Test *test, Exception *e) { cerr << " Failure at " << e->fileName() << ":" << e->lineNumber() << ": " << e->what() << endl; TestResult::addFailure( test, e ); } std::ostream& printSummary (std::ostream& os) { return os << " #test = " << runTests() << " #failed = " << testFailures() << " #error = " << testErrors(); } }; ostream& operator<< ( ostream& os, VerboseTestResult& res ) { return res.printSummary(os); } } -- by Rocket to the Moon, by Airplane to the Rocket, by Taxi to the Airport, by Frontdoor to the Taxi, by throwing back the blanket and laying down the legs ... - They Might Be Giants |