RE: [Cppunit-devel] output fix
Brought to you by:
blep
From: Bastiaan B. <bas...@li...> - 2001-05-28 09:42:59
|
-----Oorspronkelijk bericht----- Van: Steve M. Robbins [mailto:ste...@vi...] Verzonden: Thursday, May 24, 2001 5:06 PM Aan: cpp...@li... Onderwerp: Re: [Cppunit-devel] output fix 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. Me too. If I recall correctly this is what JUnit does too. 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. Obviously different people want different output. For a nice clean cutomizable output mechanism it may be worthwhile to look at JUnits' approach with the TestListener interface. That way we need only one TestResult class and no derived classes. People can simply add the Listeners they want to the TestResult. -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? Well, the synchronization object makes it difficult to make the methods const. I guess it should be possible if the synchronization object were declared 'mutable const', but I don't think 'mutable' is properly supported on all (most?) platforms yet. Bastiaan 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 _______________________________________________ Cppunit-devel mailing list Cpp...@li... http://lists.sourceforge.net/lists/listinfo/cppunit-devel |