Quantcast

Functional Testing Plugin and Transactional Rollbacks?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Functional Testing Plugin and Transactional Rollbacks?

rniedzial
I'm wondering if anyone has run into this issue, it seems that the Functional Test Plugin test methods are not wrapped in transactions like integration tests. I have several tests for which I generated different sets of data, but unlike integration tests there does not appear to be a transactional rollback of data between tests. Is this intentional? 

rafal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Functional Testing Plugin and Transactional Rollbacks?

Robert Fletcher
I'm not sure how it *could* work. If any server side code created or
modified data based on the requests the tests make those changes would
occur in a different transaction to the test itself and therefore
could not be rolled back by rolling back the test's transaction.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Functional Testing Plugin and Transactional Rollbacks?

rniedzial
The data I'm referring to is generated inside the test methods not genereated as a result of a HTTP request via the functional test. I'm trying to test different scenarios and verify the pages are rendering as expected given the different sets of data. Does that make more sense?

rafal

On Tue, May 25, 2010 at 3:19 PM, Robert Fletcher <[hidden email]> wrote:
I'm not sure how it *could* work. If any server side code created or
modified data based on the requests the tests make those changes would
occur in a different transaction to the test itself and therefore
could not be rolled back by rolling back the test's transaction.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Functional Testing Plugin and Transactional Rollbacks?

ld@ldaley.com
In reply to this post by rniedzial

On 26/05/2010, at 4:15 AM, Rafal Niedzialkowski wrote:

> I'm wondering if anyone has run into this issue, it seems that the Functional Test Plugin test methods are not wrapped in transactions like integration tests. I have several tests for which I generated different sets of data, but unlike integration tests there does not appear to be a transactional rollback of data between tests. Is this intentional?

Yes it's intentional.

It's not possible to share the transaction that the test is running in with all of the requests that your functional test creates. In short, it is not possible to use the same technique of isolating test data that is used in integration tests in functional tests. You have to take responsibility for cleaning up your own data.

A side note: automatically deleting domain data is not trivial (i.e. domainClasses*.list()*.delete(flush: true)) will more than likely fail to integrity constraints. I currently use a rather brute force technique to clean out data after functional tests which is described in the post linked to below.

http://ldaley.com/post/398082618/brute-force-fixture-cleanup-in-grails

While that example is for the Spock plugin, it can be used with any functional test plugin.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...