Peter Bell wrote, On 12/22/2006 9:43 AM:
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! :->


No, Peter... you are exactly right. I thought I mentioned it *wouldn't* be *unit* testing in my first post, but I'm guessing I didn't now that I've got 2 people explaining it to me =).

But, you did help me see that I was wrong when I said "In either case, it is important to note that if they would be there without the mocks, they will be therewith the mocks too." I had originally intended that to mean the chain will be there in the real code with the mocks, and it will be in the test code with the mocks as well. But, I didn't think it through enough. Clearly, the chain wouldn't be in the mocks/test, it would only be in the "real" code.

In any case, the "chain" of four or five that I was referring to was something along the lines of a view calling a controller which called a model which called another class that was a facade to java.sql (to create connections and statements) which also used another facade to the record set returned. Something like that anyway. You might take it a step further and say the chain ended with the classes in the sql package, and whatever they relied on.
-Sam



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/[email protected]

Reply via email to