Jeff,

One of the ways you can keep your DAO tests from affecting the rest of your application is by wrapping the entire test inside a <cftransaction> block with a high isolation level. When you are done with your set of queries for a specific test case, simply call <cftransaction action="" The database will be left as it was before you started and none of the transactions running at the same time will be aware of any changes you made during your tests.

This will only work as long as you do not use <cftransaction> inside of your DAOs--which you shouldn't since transactions are generally at the business level (multiple queries) and not the level of a single query.

I hope this helps.

Paul

On 11/28/05, Sean Corfield <[EMAIL PROTECTED]> wrote:
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 cfcdev@cfczone.org 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/cfcdev@cfczone.org





--
Paul Kenney
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.pjk.us ----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to cfcdev@cfczone.org 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/cfcdev@cfczone.org

Reply via email to