From: Tim M. <tim...@po...> - 2003-07-02 06:30:28
|
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 |