Integration Testing Adding a database file to my test project .How can I do it
I need to do some integration testing. At the moment I have some scripts that run once per assembly that create the db if not exists and populate it.
I thought it would be better if I could add a databaseFile to the test project and then just populate and clear the db accordingly. Even if this is not the best way How do I add a database file eg "MyTestDB.mdf to my project. I a开发者_JS百科m using VS 2010 premium Edition.
Suggestions?
I made some experiments with this a couple of years ago and arrived at the conclusion that the fastest way to integration test against SQL Server is to have the database itself (including schema) as an Immutable Shared Fixture, but without any data in.
As part of Fixture Teardown, all tables are truncated, leaving a clean database for the next test case. Each test case fill the database with the data it needs as part of building up its Fixture. A few years back I described this approach and it's still the best that I know of.
I've also experimented with attaching and detaching database files, but it turned out that the above process was faster.
精彩评论