From: Simon L. <sim...@uk...> - 2002-09-13 14:23:15
|
On Friday 13 September 2002 11:55, Jeff Martin wrote: > It's a general policy to not have mocks manage the relationships with > other mocks. The idea is to keep the mocks as simple as possible. > > This is the reason I've started work on the test helper classes which > setup the tree of mocks for you. Though I've not produced any for the > JDBC classes as it's more complex than the servlet api. > I can see this being helpful when there is a collection of objects that=20 need to be associated to sets of each other that have no real defined=20 (single) parent object, but the association of ResultSet to Statement to=20 Connection is a very simple child to single parent relationship. Or am I=20 missing something? My changes do the association at usage time (I didn't say that before=20 TBF), in that when a Statement or ResultSet gets returned, it is=20 automatically associated with the Object that you called to get it (I=20 can't see a situation, for JDBC at least, where you would want this any=20 different - or infact has any advantage). The set<Parent> interface is still required, as you may have methods to=20 test that take a ResultSet, or Statement, for which the parent object=20 needs manually setting. > Don't think this helps if the dependency is more than one level deep. [...] > Tempted to say forget thread safety (That's not to say it's okay to > have static variables.). > I've got a change (cvs diff -u attached) to Verifier that now at least=20 works for me. It has a static Vector (simplest why I could think of) of in verify()=20 objects, and ignores any object already being verified. It also doesn't=20 require any interface change. This solves my problem, and unless specific object implementations of=20 verify cause a loop (which was a potential problem anyway), I can't see=20 how this is any worse. Simon., =2D-=20 =2D------------------------------------------------------------------------- Simon Levitt, Senior Development Engineer @ WorldPay plc, WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND = =20 Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 =2D------------------------ http://www.worldpay.com/ ----------------------- |