From: Nat P. <nat...@b1...> - 2003-07-02 09:18:27
|
How about NOT using the call factory to create the decorator chains for toString in the constructor. Instead, create them explicitly with the new operator. The CallFactory was created so that we could test how the Mock constructed objects in response to other calls. If we have Tim's unit tests for toString then we don't need to use the CallFactory to test the mocking of toString in the constructor. Does that make sense? Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: <st...@m3...> To: <tim...@po...> Cc: <st...@m3...>; <moc...@li...> Sent: Wednesday, July 02, 2003 10:04 AM Subject: RE: [MO-java-dev] DynaMock proxy toString issue I don't believe so (I have done a little of this mock stuff before ;-). I was trying to implement Chris's idea of using the matching infrastructure to implement the special methods. It's not hard to code, but a pain to write the tests. I also suspect that MockMaker generates too much stuff. There are 24 methods on MockCallFactory of which 4 are the supported interface. It has to be possible to simplify that. S. > These tests would work exactly as specified - I think the way you are trying > to solve the problem is wrong (e.g. you have misunderstood the metaphor that > all the other tests are based on). > > Don't add the methods as defaults on construction (I think this would break > most objects in any design) - you just need to check if the method is > toString, and if an expectation/match has been set on the mock for it. > > It is literally changing the following method in mock: > > private boolean isMockNameGetter(Method method, Object[] args) { > return (method.getName().equals("toString")) && (args == null); > // to also check for expectation you need something like > // && !calls.hasCall("toString",args); > } > > > -----Original Message----- > > From: moc...@li... > > [mailto:moc...@li...]On Behalf Of > > Steve Freeman > > Sent: 02 July 2003 04:08 > > To: moc...@li... > > Subject: Re: [MO-java-dev] DynaMock proxy toString issue > > > > > > Tim Mackinnon wrote: > > > Not sure why the tests would be pain, isn't just a case of > > adding the two > > > following tests to mock? > > > > > > public void testProxyToStringWithNoToStringExpectation() > > throws Exception { > > > mockCallableAddable.addExpectedHasCall("toString", > > METHOD_NOARG_ARGS); > > > mockCallableAddable.setupHasCall(false); > > > > > > assertEquals("Should get mock name", MOCK_NAME, > > mock.proxy().toString()); > > > mock.verify(); > > > } > > > > no. If the methods are added as defaults on Mock, during construction, > > you have to fix the other tests so that calls to > > MockCallFactory.createReturnStub() don't fail because it's short of a > > return value. Which suggests that the callFactory is overspecified. > > > > > There is a smell, in some of the other tests because the > > CallFactory is a > > > bit over-used, it generates several types of stubs decorating > > each other (so > > > you have to set each of them up). I would say that this should be better > > > encapsulated so you just set one expectation on the > > mockCallFactory - the > > > tests would simplify and your code would be better. > > > > Exactly. > > > > S. > > > > > > > > ------------------------------------------------------- > > This SF.Net email sponsored by: Free pre-built ASP.NET sites including > > Data Reports, E-commerce, Portals, and Forums are available now. > > Download today and enter to win an XBOX or Visual Studio .NET. > > http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01 > > _______________________________________________ > > Mockobjects-java-dev mailing list > > Moc...@li... > > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > > > > --- > > Incoming mail is certified Virus Free. > > Checked by AVG anti-virus system (http://www.grisoft.com). > > Version: 6.0.490 / Virus Database: 289 - Release Date: 16/06/2003 > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.490 / Virus Database: 289 - Release Date: 16/06/2003 ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01 _______________________________________________ Mockobjects-java-dev mailing list Moc...@li... https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev |