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.