I'm doing system testing of a product, and several tests are severely changing the data of a demo database.
The data is quite complex to create queries which will undo the changes done by the tests; moreover, those tests are subject to change.
Using a backup/restore is not an option, since restoring the database takes 30 seconds, which is too long in a context of automated testing.
Using insert into select
is complex too: again, tests are subject to change, and can affect tables they don't affect now; copying the whole database this way is not an option neither, for performance reasons.
Microsoft SQL Server has snapshots feature, but given that I don't have Enterprise version on localhost, I can't use it. I can't use transactions neither, since the system tests involve two applications with a complex interaction between them. Of course, they don't share the same connection.
What can be done to quickly undo the last changes of a database?
To make the problem easier,
The database is in a controlled environment:
It is on localhost, so I am the only one who can access it,
The only changes are from system tests. All the changes can (and are expected to) be lost.
Any recovery model can be chosen.
The preparation (for example some sort of backup) can take long time or even be a manual task, since it would be performed very rarely. It's only the speed of undoing the changes from this point which is important, since it's done after every test which affects the database.