Re: [Cppunit-devel] Logging.
Brought to you by:
blep
From: Baptiste L. <gai...@fr...> - 2002-04-15 23:27:03
|
A clean way to do this would be to redirect cout TestListener::startTest(), and capture what was outputted by the test in TestListener::endTest(). The capture could be associated to the test and use at a latter time. Does anyone know if it is possible to redirect to an strstream (I guess not, but it would be nice) ? But are you sure you need log ? Wouldn't more advanced, specialized, or verbose assertions do the job ? If you need a log, it usually means that you need to back in time. If that is the case, it is likely that your unit tests are too complex (likely more akin to functional test). Baptiste. ----- Original Message ----- From: "John Carter" <joh...@ta...> To: <Cpp...@li...> Sent: Monday, January 21, 2002 11:36 PM Subject: [Cppunit-devel] Logging. > While I'm on the subject, I feel that there should be a logging class. > > I often 'cout << ' things as I go a long, which mucks up the pretty ...'s > > Yes, I know UnitTest's are automagic things that happen in the dark of the > night and know one should ever need to look at the logs. > > But when the nifty automagic unit test fails, one can often immediately > see why if there was a nifty log file somewhere, and hence debug the > problem faster. > > There should be a nifty way of recording things as the test goes along.... > > Something like.... > > DEBUG( "My pretty log message " << myObject.ToString()); > > which results in... > > Some meaningful and informative header giving run date, build date, > and hopefully useful CVS $Tag$ info. > filename.c:120:[MyClass::MyFunction] My pretty log message Pretty Object > > Where DEBUG is a mix of preprocessor and a invocation of a logging > utility.... > > #define DEBUG(msg) do {\ > CppUnit::Log::Instance()->PrintHeader(__FILE__,__LINE__,__PRETTY_FUNCTION__) \ > << msg << endl; \ > } while(0) > > I'm planning on doing something like that, I have most of the code lying > around anyway. What would be the best way of doing it in a manner most > likely to gain your acceptance? > > John Carter Phone : (64)(3) 358 6639 > Tait Electronics Fax : (64)(3) 359 4632 > PO Box 1645 Christchurch Email : joh...@ta... > New Zealand > > Zeitgeist shutting down for corrective maintenance, please log off. > > > _______________________________________________ > Cppunit-devel mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppunit-devel > |