From: Steve F. <st...@m3...> - 2003-06-28 00:39:30
|
Would you care to write some failing tests? As per solutions, you might want to look at the branch for Nat's latest version. Some of the names have changed. S. chris cottee wrote: > Hi all, > there's a bug/limitation in the DynamicUtil.proxyToString method > that I'd like to fix. It can't handle proxies in collections or where > the toString is called indirectly because the proxy is a field in some > other class. The reason this is irritating is that the > DynamicUtil.proxyToString method is used in displaying constraints when > call has not been matched. The result of this limitation is that if you > have an unexpected call and some other call has proxies in the > constraints indirectly then the failure message is masked by an > unexpected call to toString. > a code snippet might make this clearer: > ... > Action proxyAction1 = (Action) mockAction1.proxy(); > Action proxyAction2 = (Action) mockAction2.proxy(); > Collection listOfActions = new TestVector(proxyAction1, proxyAction2); > > mockConfigVersion.expectAndReturn("applyToSubConfigs", > C.eq(versionRepository, listOfActions), true); > ... > > The DynamicUtil.proxyToString will not be able to display the > listOfActions properly so any failed expectation on mockConfigVersion > will be hidden by an unexpected call to "toString" on mockAction1. Lots > of time will then be spent stepping > through the code to find which call went wrong. This has happened to me > often enough to be a nuisance. > > The solution I propose is to not use the DynamicUtil to handle the > toString and instead make the default behaviour of a proxy toString call > to be to return the name of the mock. This would be overriden if an > expectation was set on the toString or you could use the reset method to > clear it. The reason I think it should be done this way is that I can't > see how the DynamicUtil can be made to handle all the possible ways that > the toString might be called on the proxy. Also I think it is unusual to > need to set an expectation on toString (I have never done it other than > to get around this bug) but less unusual to use proxies inside other > objects which are used in constraints. The way I had thought of > implementing this behaviour is to add a match of toString into the > callableAddable of the Mock on construction. > > Any thoughts? > Chris > > > > ------------------------------------------------------- > 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 |