This is a really good question!

I've done similar things in my unit tests, by cheating a little, and
it worked a charm.

I can't seem the find the code... but the basics went something like
this (written in gmail, so errors will happen):

<cfcomponent extends="frameworkYouUse.TestCase">

   //wrap everything in a transaction
   application.transferFactory.getTransaction().advise(this, "^test");

<cffunction name="tearDown">
  //dump the cache after every test
  <cfset application.transferFactory.getTransfer().discardAll();

<cffunction name="testFoo">
  <cfset assertTrue(...) />

  <!--- rollback any processing that you've done --->
  <cftransaction action="rollback" />


Using a combination of discardAll() and <cftransaction> you could roll
back your data and your cache quite happily.

There is an enhancement ticket for you to be able to start() and
stop() transactions on your own, but this way works pretty well as


On Wed, Jan 21, 2009 at 11:44 AM, bimp <> wrote:
> I'm trying to devise a method of rolling back database operations in
> Transfer for unit testing purposes. After reading about leveraging the
> Transaction object advise() implementation (http://docs.transfer-
>, I tried creating a
> function called 'rollback()' that is wrapped by the advise() method
> along with all my other 'save()' functions.
> Then only in unit testing implementations, I would execute the
> 'rollback()' function which does a <cfthrow> operation. I thought from
> the docs that this would effectively rollback all the database and
> Transfer operations but nothing happened. The <cfthrow> occurred but
> the database records still existed. Am I using the Transaction advise
> () function correctly?
> Is there a way to execute a tranasaction rollback using the advise
> implementation?
> Thanks.
> >


Before posting questions to the group please read:

You received this message because you are subscribed to the Google Groups 
"transfer-dev" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to