Oh that's sweet. I didn't know version 2 was out now. I'll be using that for my db calls now for sure.
-Sam

Kurt Wiersma wrote, On 12/21/2006 6:12 PM:
Robert Blackburn developer of cfUnit has a nice post about a mock object testing setup he created.

http://rbdev.net/devblog/index.php?entry=entry061128-130441 <http://rbdev.net/devblog/index.php?entry=entry061128-130441>

--Kurt

On 12/21/06, *Jeff Chastain* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:


    There is always a need for both unit and integration testing, I
    just don't
    like mixing them.  Part of test driven development as I understand
    it is to
    write the test for the object, then develop the object.  How do
    you do this
    if you first have to write the dependent objects?  There is a
    reason for the
    popularity of the mock and stub frameworks in other languages ...
    it makes
    testing more precise.  Yes, you may never run into problems with a
    dependent
    object breaking the object you are testing, but I don't really see
    that as a
    reason to allow the possibility.  If it did happen, you could have
    a long
    dependency chain, part of which you might not be able to test (the
    event
    object in Mach-II for example) and debugging would be as difficult
    as it
    would be without unit tests.

    I have just seen a lot more posts recently about unit tests and
    TDD, but I
    have not seen any examples short of very simple objects with no
    dependencies.

    Thanks.


    -----Original Message-----
    From: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
    [mailto:[EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>] On Behalf
    Of Sammy Larbi
    Sent: Thursday, December 21, 2006 5:47 PM
    To: cfcdev@cfczone.org <mailto:cfcdev@cfczone.org>
    Subject: Re: [CFCDEV] TDD for ColdFusion


    Jeff D. Chastain wrote, On 12/21/2006 4:00 PM:
    > This is a cross-post with CF-Talk, but I figured this list is a bit
    > more cfc oriented.  I am really trying to get into test driven
    > development as the benefits are fairly obvious after having done
    > development any other way.  However, in terms of doing this with
    > ColdFusion, I am either not getting it or there is a lot of talk
    going
    > on regarding TDD, but not much in actual practice.
    >
    > My biggest issue comes with object dependencies.  Ideally, your
    > objects are as loosely coupled as possible, but it is simply not
    > possible to have an application full of completely disjoint objects
    > with no dependencies at all.  One of the premises of unit testing
    > though is to test only the functionality of one individual object or
    > unit and not test all of its dependencies.  Other languages
    appear to
    > handle this with mock objects which allow for simulating and
    testing
    > any object dependencies.

    Of course, you could directly test those too.

    > However, the mock object frameworks for Java and other languages
    > simply don't port to ColdFusion because of language construct
    > differences.  Without a mock object framework, the only other
    option I
    > see is to hand create and maintain stub or mock objects, and
    this just
    > does not seem like a feasible practice in an application of any
    size.
    >

    A while back, I thought of attempting to develop a mock object
    framework for
    CF (or better put, I thought about thinking about it).  But, as I
    explain
    below, I haven't seen much use for one in my own development, so
    I've pretty
    much dropped the idea.

    > So, how do you test ColdFusion objects when there are dependencies
    > involved?
    >

    I haven't yet found myself in need of a "true" mock.   In cases where
    I'm testing class A which does have a dependency B, I go ahead and
    create
    the stubs in B as I need them, and let that class grow into the
    real thing
    over time, as needed.  I don't think there's anything wrong with
    integration
    tests - in fact, we need those too.  In the cases where I have
    needed "unit"
    tests (in the proper sense of the term), I might then go ahead and
    hand
    create class C, which is basically a "mock" that extends B.  It's
    not really
    a mock (well, we had a huge discussion about this on the TDD list
    a couple
    of months ago), but it serves the purpose of basically truly
    isolating A.
    In any case, I don't find that need
    happening often.   Further, I haven't noticed that I've ever
    gotten into
    trouble when something in B breaks the tests for A - it's normally
    pretty
    obvious, even if it doesn't break the tests for B.  In fact, I've
    often had
    more trouble with my fake "mocks" than with my integration tests.  Of
    course, this phenomenon is not unique to me in Coldfusion.
    I've also experienced it in Java.  Ron Jeffries talked about never
    (or very
    rarely) needing to use a "proper" mock as well.

    Does that make any sense?

    -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 <http://www.katapultmedia.com>

    An archive of the CFCDev list is available at
    www.mail-archive.com/cfcdev@cfczone.org
    <http://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
    <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 <http://www.katapultmedia.com>

    An archive of the CFCDev list is available at
    www.mail-archive.com/cfcdev@cfczone.org
    <http://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



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

Reply via email to