My tech blog

To rollback or not to rollback

leave a comment »

I have just read some comments in a Spanish group about how to test the persistence layer.
So far, I was happy using Spring Test Framework to roll back after each test. However, some people say that rolling back does not completely test the code. The book Growing Object Oriented Software says this about it:

A test that never commits does not fully exercise how the code under test interacts with the database. Neither can it test interactions between distinct transactions. Another disadvantage of rolling back is that the test discards data that might be useful for diagnosing failures

The alternative to rolling back is to create a well-known state of the database before each test using the builder pattern rather than DBunit, whose xml files are normally more difficult to maintain.


Written by alexcuesta

October 18, 2010 at 4:20 pm

Posted in Java

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: