On 11/27/05, Jeff Chastain <[EMAIL PROTECTED]> wrote: > What would a unit test (either CFUnit or CFCUnit) look like for a DAO > object? For example, would the test for the the create function pass in a > bean, then call the read method and somehow compare the returned bean with > the original bean? Does anybody have an example of a unit test for a DAO?
Well, there are a lot of answers to this... I asked Rob Blackburn about DB testing and got an essay back in response. A lot depends on exactly what you are trying to test. You could: a) write the test to just call create / read / update / delete methods on the DAO and check that you get back expected results (create an object and read it back, update an object and read it back, delete an object and ensure you get an error trying to read it back) b) write the test to call CRUD methods but then do a raw select query to test what is actually in the data c) write the test to manipulate the database with raw CRUD queries and then call the CRUD DAO methods d) ... probably other options ... Personally, I'd go with (a) so the test case does not need to know about the database but there are certain situations where both (b) and (c) might be useful. Bear in mind also that most DB-related testing is history-sensitive, i.e., your tests affect the database in ways that might also affect your application. -- Sean A Corfield -- http://corfield.org/ Got frameworks? "If you're not annoying somebody, you're not really alive." -- Margaret Atwood ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
