This post was originally published at http://solepano.blogspot.com
It seems that testing DALs is harder than I thought. One of the problems I have run into is how to preserve DB integrity. Some of the alternatives are:
- Create mock objects that replace the database.
- Have a separate DB for testing.
- Restore the DB on every test run.
- Run the test inside transactions and then rollback.
Another concern is: How the tests must be designed in order for their success or failure to depend only on the coding and not on the data state?
Related LinksTesting Frameworks:
Unit Testing in .Net Proyects by Jay Flowers
Transaction approach:
Simplify Data Layer Unit Testing using Enterprise Services
Alternative Testing Frameworks
Mock Objects:
Mock Objects to the Rescue! Test your .NET code with NMock
Mocks Aren't Stubs by Martin Fowler
Testing sequences (useful for CRUD operations):
Advanced Unit Testing, Part III - Testing Processes by Marc Clifton