I want to implement automated testing using the Microsoft testing environment in Visual Studio for my software development projects. I have created several tests, and all this is quite easy to use.
What are the best practices for testing business objects , more specifically those that read and write to the database.
Is it better to set up a separate test database from the development database with which the user interface is tested, and just test this database? Mostly just filling it with junk data.
Are you better off accepting some kind of cleanup after your mentality, that is, if I am testing the AddUser method, am I adding a user, checking my tests and deleting the user?
Do you test each of the CRUD methods with a single test method?
Finally, with regard to individual business rules, such as checking rows, the correct size, start dates less than end dates, CustomerId is the right Client, etc.
I understand that this is a rather broad question ... just looking for some direction ... taking children's steps.
Additional Information...
Lots of good answers! I'm not sure I can pull out the database. I use CSLA as the basis for my objects. Serious refactoring will be required to verify this with mock objects. I will do it. Although, at some point, I want to test the interaction with the database ... when using the mock database, where / when will you really check the connection with the database?
One more question ... is it better for each testing method not to depend on other tests?