Hi Jeff. Yes, you have to tell the mock object what you're expecting it to return, so that the object being tested (your service in this case) interacts with the mock the same way it would interact with the real object. You'd do this in your unit test methods. So in your case, you'd mock a business object, then mock the DAO, and finally tell the DAO that when the service calls the method on it, it returns the business object. The whole point is that the only "real" object you're testing at a time is the object you actually want to test. Everything else is fake. Does that make sense or am I misreading your question?
On Nov 12, 2007 4:16 PM, Jeff Chastain <[EMAIL PROTECTED]> wrote: > I have been playing with Brian Kotek's ColdMock factory > (http://coldmock.riaforge.com) in doing some unit testing for an app I am > working on. In this case, I have a service object that needs to retrieve > a > record from the database via a DAO. I only want to test the service > object > and not the DAO / database, so I am trying to use ColdMock to create a > mock > DAO object that just returns a business object with some hard coded data. > > > > The problem is, when my service goes to ColdSpring and requests the DAO, > ColdSpring returns the mocked up DAO. However, that mocked up DAO does > not > contain any test data - in other words, if I call a function on that DAO, > it > throws an error. On Brian's site, he has code showing how to tell the > mock > object what to return when a function is called, but I can't see how to > work > that extra bit of code into the ColdSpring scenario. When my service > calls > ColdSpring to create the mock DAO, I would have to code in the extra > functionality at that point which is no good considering the service is a > real production object and should not know anything about a mock object. > > > > Am I missing something here with regards to how mock objects work or > should > function? > > > > Thanks > > -- Jeff > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Get involved in the latest ColdFusion discussions, product development sharing, and articles on the Adobe Labs wiki. http://labs/adobe.com/wiki/index.php/ColdFusion_8 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:293156 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

