Quantcast

data gone after test-app with datasource=update

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

data gone after test-app with datasource=update

interz
Hi,
Grails 0.6.

I have my unit/integration tests accessing my database with data in it. The "test" datasource is in "update" mode. After running test-app, my data is gone even though my integration tests for the domain classes do nothing. I have to restore from a database backup after running "test-app"

suggesstions?


Building a website is a piece of cake.
Yahoo! Small Business gives you all the tools to get online.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: data gone after test-app with datasource=update

M Stewart
interz12 wrote
I have my unit/integration tests accessing my database with data in it. The "test" datasource is in "update" mode. After running test-app, my data is gone even though my integration tests for the domain classes do nothing. I have to restore from a database backup after running "test-app"
Hi Interz,

Pretty sure this behavior is intended operation though, like a lot of Grails, it isn't actually documented. The framework deletes the data for all the referenced domains for each test so that it is in a known state and tests can be written independently.

While the datasource mode can have a similiar effect in other contexts (if you use create-drop) I think the 'update' mode is more about the schema than the data contained (e.g. should a new column be added to a table.)

I could be completely wrong about all of this but it seems consistent with my own experience. I'm going to edit the wiki to at least mention the delete-after-test-method behavior since I was confused about that as well.

::mark
Loading...