Re: [Cppunit-devel] Bug or misunderstanding?
Brought to you by:
blep
From: Baptiste L. <gai...@fr...> - 2003-01-07 09:33:34
|
----- Original Message ----- From: "Duane Murphy" <dua...@ma...> To: <Seb...@en...>; "CppUnit Developers" <cpp...@li...> Sent: Friday, December 20, 2002 12:00 AM Subject: Re: [Cppunit-devel] Bug or misunderstanding? > --- At Fri, 20 Dec 2002 11:45:45 +1300, > Seb...@en... wrote: > > >Hi, > > > >I'm just starting on a new project and we are going to use CppUnit as a > >framework for our tests. Right now I'm working on the UI part of the > >application and so I started out with creating a Fixture that contains a > >UserInterface object as a member and has a static suite() function just as > >described in the CookBook. The suite creates two (for now) TestCallers and > >pass in test methods of the fixture. I expected one Fixture (and therefor > >one UserInterface) to be created and that all the testmethods are called on > >this one object (framed by calles to setUp() and tearDown() which reset the > >UI object to a > >known state.) > > > >However, it turned out that for each TestCaller instantiated one Fixture > >was instantiated and the testmethods were each called on a different > >Fixture object. This resulted in multiple UI objects to be created and > >since they create threads each calling a display driver which only expects > >calls from one UI at a time ..... I think you can imagine ... > > > >My understanding came from the following text from the CookBook: > > > >"Ordinarily, you'll have many little test cases that you'll want to run on > >the same set of objects. To do this use a fixture. [...] A fixture is > >a known set of objects that serves as a base for a set of test cases." > > > > > >Now my question is: Am I doing something wrong or is this a bug in CppUnit > >or is this intended behaviour (in which case I think the docu should be > >updated.)? > > > >Also if this is intended, can you give me just a pointer on how to do this > >kind of thing? Should I subclass TestSuite and keep the persistent objects > >there? > > 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. > CppUnit likes calling new() :-). What do you mean ? Baptiste. [...] > ...Duane |