Re: [Cppunit-devel] Bug or misunderstanding?
Brought to you by:
blep
From: Duane M. <dua...@ma...> - 2003-01-08 16:35:57
|
--- At Tue, 7 Jan 2003 10:38:34 +0100, Baptiste Lepilleur wrote: >> >> Others that work on CppUnit can speak up for why it is this way. I have >> long considered this a bug. CppUnit likes calling new() :-). They >> instiate a new Fixture() for each test case. You will have to work around >> it somehow. > >This is a normal behavior. It provides maximum isolation between each test >case of the fixture. As far as I know JUnit behave the same way. There is a chance I missed something, but from my brief review of the JUnit code and especially the JUnit articles and examples I have read, it appeared to me that the point of the Fixture was indeed to manage the a set of tests and not a single test. If it was meant to manage a single test that what is the point of setUp() and tearDown()? I could just as easily do these in a constructor or a destructor. >> CppUnit likes calling new() :-). > >What do you mean ? I find the use of new() to be a liability. It is the leading cause of memory leaks and object lifetime errors. I have in fact had bugs with CppUnit where the lifetime of an object was indeed shorter that I had expected. I avoid pointers and unmanaged memory as much as possible. I use references and shared pointers (from boost) for all of my memory management. This makes the code safer, more stable, and easier to read and understand. I view projects like CppUnit() as "industry examples." Maybe this is too strong of an expectation, but I would expect to see "best practices" in a widely used framework like CppUnit. I view memory management as a best practice. ...Duane |