This is a very hard problem in general. Here are a few different approaches:
1. Use [Rollback] in MbUnit to automatically rollback changes made to the Db during a test. This assumes that the subject under test is enlisting its transactions the usual way. 2. Drop & recreate the database schema. Not always an option. 3. Create a temporary snapshot of a baseline database for testing purposes. (http://msdn.microsoft.com/en-us/library/ms175876.aspx) 4. Backup and restore the database from a known snapshot. This can work quite well if the database is small. 5. Give up and write stateful and persistent integration tests. (last resort) We could definitely use some better tooling in this area... Jeff. -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Henning Sent: Wednesday, November 05, 2008 11:38 AM To: MbUnit.User Subject: MbUnit Reseting Database to known state Hi, so after I created all my domain-entities and mappings (NHibernate) I would like to test if the mapping to the actual relational database works as expected. OK, so far no prob - just write a couple of unit-tests. But obviously I should "reset" the db for each test, so that I always have a consistent and known state. So how would I do that? The naive way would be to drop everything and have the SchemaExporter of NH recreate everything. That's what I did so far - up until now. Now I have an existing relational model which I must use, so I can't just drop and recreate everything. Does anyone have a tip on how to achieve setting the db to a known state for unit-testing? Ideally I would like to have some way which is actually usable for various db-systems (currently I have to work with Oracle, but most of the time I use MSSQL2005). I stumbled across a tool called "ndbunit" - but the site seems down :( --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MbUnit.User" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/MbUnitUser?hl=en -~----------~----~----~----~------~----~------~--~---
