RE: [Cppunit-devel] hierarchy sample bug...
Brought to you by:
blep
From: Bastiaan B. <bas...@li...> - 2001-05-07 09:06:30
|
-----Oorspronkelijk bericht----- Van: Baptiste Lepilleur [mailto:bl...@cl...] Verzonden: Sunday, May 06, 2001 2:12 PM Aan: cpp...@li... Onderwerp: Re: [Cppunit-devel] hierarchy sample bug... --8<-- > That is correct behaviour. The BoardGameTest checks invariants that should hold > for all BoardGameTest instances, including Chess objects. The testReset() > method in BoardGameTest should equally apply to Chess objects. Overriding > testReset() in ChessTest is a serious indication that the design of application > is flawed. I agree with that. Though in some case you might have some "template method" (the pattern) in your test case. I can see that applying when you have some specific behavior and want to factor some testing part. An example that pop up into my mind would be testing visitor/strategy/builder. The setup of each test may be identical and you would want to factor out those part in a base class. Then, you would use the self-shunt pattern (having the test case implementing the visitor interface...), and delegate part of the actual test to the derived test case. OK, you got me there! :-) > However, there is one problem, which may be what you hint at: the current > BoardGameTest implementation implies that all BoardGame classes have a default > constructor and need no further setup. This is indeed the main problem I see. You want the setUp() and tearOff() method of your derived class to be called: initialization of the "game" class, initialization of the default database connection for the current thread... I've implemented the fix I suggested yesterday: TestCaller now has two extra constructors which accept either a reference or a pointer to an existing fixture as an extra parameter. Now GameBoardTest constructs a TestCaller with *this as Fixture and the correct setUp(), tearDown() and testmethod are called. I don't see why every TestCaller needs its own Fixture instance, so if there aren't any objections I'd like to deprecate the old constructor. Please let me know if you see any flaws in this approach. Bastiaan Baptiste. --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html Author of The Text Reformatter, a tool for fanfiction readers and writers. Language: English, French (Well, I'm French). _______________________________________________ Cppunit-devel mailing list Cpp...@li... http://lists.sourceforge.net/lists/listinfo/cppunit-devel |