Thanks for the response Matt. I'll repost this there. In the meantime for 
anyone else viewing this thread, what I'm struggling with is finding out if the 
save occurred successfully. Maybe the answer is that I should be unit testing 
the model directly and ignoring this test within the handler's unit tests. 
Here's what I'm thinking this unit test should look like (partial pseudo-code):

     <cffunction name="testEditAction">
                <cfargument name="event" type="any">
                <cfscript>
                        var event = "";
                        var rc = '';
                        var testObj = '';

                        // set up fake form submission
                        rc.userID = 1;
                        rc.userName='testUser';
                        rc.password = 'testPass';
                        rc.departmentID_fk = 1;

                        event = execute("demoApp.edit");
                        rc = event.getCollection();
                        debug(rc);
                        
                        testObj = createObject('component','path.to.users');
                        testObj.load(rc.userID);
                        
assertEquals(testObj.get('username'),rc.username,'usernames are not equal.');
                        
assertEquals(testObj.get('password'),rc.password,'passwords are not equal.');

                </cfscript>
        </cffunction>

... but you can see how this is a MUCH bigger function than what I'm actually 
trying to test. If I used this approach in a more complex scenario, I could see 
it taking twice as long to write the test than it did to write the 
functionality I'm trying to test... Seems like a losing battle - I'm hoping I'm 
missing something? 

Thanks!

>Jake,
>
>I would highly recommend posting this question to the ColdBox and/or MXUnit
>groups (links below).  You are almost guaranteed to get a much greater
>response from those than you will from CF-Talk.
>
>/0.02
>
>I would offer a suggestion, but I'm honestly not exactly sure what you're
>trying to do, or specifically, what you're struggling with.  But that might
>be just because I a) don't use any of the built-in model stuff, and b) don't
>really write controller unit tests.  I write extensive tests on my model
>itself, but typically just browser test the controllers.
>
>HTH 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322457
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to