EntropyZero Blogging Server

Welcome to EntropyZero Blogging Server Sign in | Join | Help
in Search

dataFresh - a new database rollback library for unit tests

Quickly put your database into a known state for testing.

How to use dataFresh for database unit testing

In this post I will walk you through the steps of implenting dataFresh into your testing framework. A few of our users have reported issues but as it turns out, dataFresh was simply improperly being called.  Here is my attempt to provide more documentation. :)

The first thing you should know is that dataFresh is an API that should be integrated directly into your testing framework.  The console application knows how to pass parameters and simply make calls to the API.  It is only nessessary to use the console application if you wish to manually execute dataFresh commands against your database.

Step 1 : Prepare your Database

Before you can call any other dataFresh method you must first prepare your database with the nessesary stored procedures, table and triggers.

Step 2 : Create a Snapshot

Whenever your database schema or test data changes you are required to create a snapshot of your database in order to perform a successful rollback.  When using a tool like deltaRunner, you can easilly manage updates to your database and automatically create a new snapshot.

Step 3 : Run your Test

You should feel free to write your integration tests that communicate with and make changes to your database.

Step 4 : Refresh the Database

A quick call to the RefreshTheDatabase method and dataFresh will very quickly restore only those tables that were modified during your integration test.

Now in practice, we typically check for modifications and refresh the database during the setup method of our test fixtures.  After the test runs, it has been my experience that there is some benefit of being able to run queries to check the state of the database as it were modified after the test.  We usually use the tear down method and output a "Database Write" message just so that we have something visual.

We have provided sample code that demonstrates the recommended implementation.

 

 

Published Sunday, October 22, 2006 2:28 AM by mike.brockey

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

silvere said:

Does this tool support mysql?

and how it works?

thanks.

sunjingwei@baidu.com

May 12, 2008 4:25 AM

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server, by Telligent Systems