Peter - This is exactly correct in my understanding. Unit testing should test individual objects versus integration testing should test multiple objects "integrated" together.
The only way you can perform a true unit test on an object with dependencies is to stub out those dependencies. A stub object will simply return "correct" dummy data from a method called. A mock object will take this one step further and provide another set of validation assertions that can be run. Things like asserting that the correct method on the dependent was called N times and that other methods were not called etc. The exact capabilities of mock objects seem to differ based upon the framework, but at the most basic level they are a stub object with additional checking. -- Jeff ---------------------------------------- Return-Path: <[EMAIL PROTECTED]> Fri Dec 22 09:45:05 2006 Received: from 65-182-193-53.rev.sdf.hosting.com [65.182.193.53] by G1D-2 with SMTP; Fri, 22 Dec 2006 09:45:05 -0600 Received: from mail.freshstartsoftware.com [72.9.248.10] by dws047.dedicated.expresstech.net with SMTP; Fri, 22 Dec 2006 10:44:52 -0500 Received: from cpe-24-193-19-202.nyc.res.rr.com [24.193.19.202] by mail.freshstartsoftware.com with SMTP; Fri, 22 Dec 2006 10:43:24 -0500 User-Agent: Microsoft-Entourage/11.2.5.060620 Date: Fri, 22 Dec 2006 10:43:05 -0500 Subject: Re: [CFCDEV] TDD for ColdFusion From: Peter Bell <[EMAIL PROTECTED]> To: "cfcdev@cfczone.org" <cfcdev@cfczone.org> Message-ID: <[EMAIL PROTECTED]> Thread-Topic: [CFCDEV] TDD for ColdFusion Thread-Index: Accl397YHXWWHpHTEduhaQAWy8qbRg== In-Reply-To: <[EMAIL PROTECTED]> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit reply-to: cfcdev@cfczone.org precedence: list sender: [EMAIL PROTECTED] X-SmarterMail-Spam: BAYESIAN FILTERING, SPF_None X-Rcpt-To: <[EMAIL PROTECTED]> Hi Sammy, Just got to jump in on a point here . . . > I'm not familiar with Mach-II, but I would have thought long dependency > chains are not generally advisable. And I'm certainly no expert on > that, so I could well be wrong. I can't remember a time when I've had > more than 4 or 5 in a chain though. In either case, it is important to > note that if they would be there without the mocks, they will be there > with the mocks too. And still further, if you had been doing what I > attempted to describe, all of it would be under test (that I can see - > but I may certainly have not explained it well enough, or I could be > missing something). The same cannot be said if you are only using > mocks, however. Lets imagine that ObjA calls ObjB calls ObjC calls ObjD (not best practice, but it does happen sometimes with complex models and interactions). If you mock ObjB then ObjA calls MockB which (if I get mocks right) just stubs out and responds as appropriate to calls from ObjA. If you don't do this you aren't really doing unit testing because you're doing a functional test on ObjA, ObjB, ObjC AND ObjD when you run your "unit test" on Obj A and all of them have to work right for the test to pass so your ObjA test ISN'T testing the single unit of ObjA but it's entire dependency chain. I have very little sense of unit testing in practice yet, so let me know if I'm missing anything here! :-> Best Wishes, Peter You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm CFCDev is supported by: Katapult Media, Inc. We are cool code geeks looking for fun projects to rock! www.katapultmedia.com An archive of the CFCDev list is available at www.mail-archive.com/cfcdev@cfczone.org You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm CFCDev is supported by: Katapult Media, Inc. We are cool code geeks looking for fun projects to rock! www.katapultmedia.com An archive of the CFCDev list is available at www.mail-archive.com/cfcdev@cfczone.org