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">

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

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

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

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

</component>

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
well.

Mark

On Wed, Jan 21, 2009 at 11:44 AM, bimp <bpa...@gmail.com> 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-
> orm.com/wiki/Transactions_and_Transfer.cfm), 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.
> >
>



-- 
E: mark.man...@gmail.com
W: www.compoundtheory.com

--~--~---------~--~----~------------~-------~--~----~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

You received this message because you are subscribed to the Google Groups 
"transfer-dev" group.
To post to this group, send email to transfer-dev@googlegroups.com
To unsubscribe from this group, send email to 
transfer-dev-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/transfer-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to