Re: [Cppunit-devel] Bug or misunderstanding?
Brought to you by:
blep
From: Duane M. <dua...@ma...> - 2002-12-19 23:00:42
|
--- 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. I worked around it by making a few additions to the CppUnit code to allow me to register test cases that all share a single Fixture; which is how I always thought the system should work. I could dig into my code to find the changes that I made if you would like. ...Duane |