I don't know how Robert did it, but I can see how it might be done.
1) instantiate an object of the type passed in to your init method
2) write a temp cfc that extends it. inject your own methods into that cfc.
3) instantiate the temp cfc and return it in your init method
3) overwrite the inherited methods as needed
Robert may have a more elegant way than writing to a temp file, but none
of mine seemed to work (for instance, in the past I've made parents
become their children based on expectations of the user, but that only
works if the child already extends the parent.)
I could also see injecting your own methods into the object, along with
some blank functions as pointers... perhaps using closures when the user
overrides a function (which would probably need to be done in the first
one anyway)... but even that would require writing to a temp file.
-Sam
Peter Bell wrote, On 12/21/2006 9:29 PM:
I haven't made the TDD jump yet (top resolution for next year - that and
FitNess for integration testing), but I'm having a hard time understanding
how you'd do unit testing WITHOUT some kind of mock object.
BTW, have you blogged about HOW you implemented the mock object? I'd love to
get an idea of the approach you used (I WILL download the source code and
figure it out, but was wondering if you'd give the lazy part of me a hint
first!).
Best Wishes,
Peter
On 12/21/06 10:17 PM, "Robert Blackburn" <[EMAIL PROTECTED]> wrote:
Thanks for the reference to my post Kurt :o)
I just responded to Jeff's CF-Talk post, but I figured I would follow
up here too.
The mock object is still a rather new feature of CFUnit (only
available in the v2.0 beta). And I must admit at first I was not sure
how frequently mock objects might be used in CF unit testing. But
since launching this I have been using it a lot in my own work. And it
has been a real boon to the stability and quality of my tests.
On 12/21/06, Kurt Wiersma <[EMAIL PROTECTED]> wrote:
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
--Kurt
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]
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]