I am trying to find out in Visual Studio 2010 Unit Testing how to keep a transaction of the data I have either added, updated, or deleted during my tests so on my TestCleanup I can rollback their values.
What search terms should I be using to find more about this?
Cheers
Paul
Why do you need to rollback changes? Are your unit tests updating live data? If unit tests are written properly, you shouldn’t have to clean up after what your tests changed because the data they’re changing should be isolated to your test.
Edit:
It sounds like you’ve set up a data set for testing and want to make sure that data set is restored back to its original state. I prefer the practice of setting up the test data as part of the test, but I understand that can get difficult for complex tests.
If this in an ADO.NET data source, you could start a transaction then roll back that transaction at the end of your test. For example:
Edit 2:
A third option, if you don’t have transaction support, is to have a backup of your test data in a place where it won’t get modified, then at the end of the test, restore that backup.