For the help, here is my environment:
- Visual Studio 2010 and c#
- Sql Server 2008 R2 with Sql Management studio
- NUnit
I'm in the process of creating a lot of integration tests that will interact with a database. Each test must have a database in a very specific state. I don't want to insert data with an ORM or directly with Sql Management studio.
What I want is a couple of sql scripts with a structure same like VMware snapshots.
For example:
--> [Main script with system tables like tables mapped to enum].sql
-- --> [A couple of rows in some tables].sql
-- -- --> [A couple of other rows in other tables].sql
-- --> [A couple of rows for another test].sql
-- -- --> [A couple of other rows for handle others cases].sql
With this type of structure, I will be able to rollback to a specific version of snapshot to set the database in a specific state and than create another branch of snapshots in the structure.
Before each tests, I clean all tables in the database and then execute a specific sql script.
Is it a good way to do integration tests with database?
Does exist tool to do this type of sql script structure?
Do you a a list of bests practices?
If it's not a good idea what I want to do, what is the best architecture, methodology to do this type of tests?
Thank you very much.