Unit Testing DAOs with CFCUnit setUp() and tearDown()
I recently starting Unit Testing with CFCUnit. Unit testing is not a new topic in the CF community, but it is new to me. I've found that there are a lot of aspects related to unit testing (like Mock objects and stubs) that you need learn about. As I continue to read and research unit testing techniques, I've seen items that go back years. One topic that I could not find a lot of information on is how to test DAOs and the SQL code in <cfquery/> tags. After rephrasing my serach terms a few times, I found a great post by Robert Blackburn that also lead me to a suggestion by Paul Kenney on the old CFCDev list to wrap the test within <cftransaction/>. I liked the idea of using <cftransaction/>, but decided to try something a little different.



I assume an example test case would run a method that changes the database, read back the record to confirm the change, then rollback the transaction?
Now that this post is 45 days old - how is this approach working for you?
Thanks for the feedback. You're correct regarding a test case. If I'm testing a insert() or create() method, I perform a few operations in a single test case. First selectAll() and store the number of records, perform a insert, then test that another select is greater than the last by 1.
At the time that I needed this solution, I was building a test suite and was completely satisfied with the approach. Unfortunately, since that time, I haven't had much opportunity to work with it. :(
Even though I have a dev DB, it feels much better to clean up after inserts.
Thanks and hope to see you at CF.Objective()
Thanks for the comment. I use this setup with a dev database as well.
I really looking forward to meeting people at cf.O(). My first CF conference.
http://mytoysglzbepydlu.blogspot.com
http://toyswwdauay.blogspot.com
http://rijwzjzvq.blogspot.com
http://abdnpzkwi.blogspot.com
http://minermugttnpef.blogspot.com
http://supermanyccyfuvqsw.blogspot.com
http://classictvwiixmeiu.blogspot.com
http://tomjtfykq.blogspot.com
http://ringringmtgypg.blogspot.com
http://retrotvdiajvdishgo.blogspot.com
http://retrostuffdyazorez.blogspot.com
http://spockeabaeaepwxd.blogspot.com
http://thispygerqtv.blogspot.com
http://bloghteejhoj.blogspot.com
http://careffrxpvw.blogspot.com
http://drugykroxxcsi.blogspot.com
http://captkirkhglblk.blogspot.com
http://abebwvoxvw.blogspot.com
http://efanctnvfrztt.blogspot.com
http://gunslnlmm.blogspot.com
http://crowszgwjocqh.blogspot.com
http://batmanxrmwrybgo.blogspot.com