From: Gilles D. <rh...@wa...> - 2002-08-23 10:00:28
|
Hi, I think MockObjects are missing a feature very useful when working with f= actories. imho they should follow the Composite pattern. For instance, let= 's say i wanna use a MockConnection : i need a MockPreparedStatement and a= MockResultset as well. If i want to externalize the creation of my MockOb= jects from the TestCase perspective (ok thats perhaps arguable), i have n= o practical way to do it, since i will have to call verify() on both myMoc= kPreparedStatement and myMockResultset as well. But since the creation of = the MockObject was delegated, i lost the references to those objects (and = also Verifier.verifyObject() doesnt verify myPreparedStatement : it just e= nsure that it has been used). There's also a crappy work-around : using AspectJ, we can these functionn= ality at the price of extending MockConnection, MockPreparedStatement and = MockResultSet. thats not satisfactory tho. so the better way i think would= be to modify MockObject class to make it composite. What do you think of = this =3F -- gd |